Skip to content

[SP-374] Fix JSON file upload MIME detection in Ruby SDK - #228

Merged
dvacca-onfido merged 1 commit into
masterfrom
fix/ruby-json-mime-detection
Aug 24, 2026
Merged

[SP-374] Fix JSON file upload MIME detection in Ruby SDK#228
dvacca-onfido merged 1 commit into
masterfrom
fix/ruby-json-mime-detection

Conversation

@dvacca-onfido

Copy link
Copy Markdown
Contributor

Problem

Marcel::MimeType.for(Pathname) relies on magic bytes and fails to detect application/json for .json files, returning application/octet-stream instead. This causes a 422 validation error from the API when uploading NFC data via onfido-ruby.

Fix

Added a fallback in api_client_faraday_partial.mustache: when Marcel's pathname-based detection returns application/octet-stream, fall back to Marcel::MimeType.for(extension:) which correctly resolves the MIME type from the file extension.

This aligns Ruby with all other SDKs (Python, Java, PHP, Node) which already use extension-based MIME detection.

Testing

…s (SP-374)

Marcel::MimeType.for(Pathname) relies on magic bytes and fails to detect
application/json for .json files, returning application/octet-stream instead.
This causes a 422 validation error from the API when uploading NFC data.

Add a fallback to Marcel::MimeType.for(extension:) when the pathname-based
detection returns application/octet-stream, aligning Ruby with all other SDKs
which use extension-based MIME detection.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@dvacca-onfido dvacca-onfido self-assigned this Aug 24, 2026
@dvacca-onfido
dvacca-onfido merged commit 6d0dfd9 into master Aug 24, 2026
7 checks passed
@dvacca-onfido
dvacca-onfido deleted the fix/ruby-json-mime-detection branch August 24, 2026 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants