fix: map InvalidFileTypeError in error-map and allow image/heic uploads#299
Open
islandbitcoin wants to merge 2 commits intomainfrom
Open
fix: map InvalidFileTypeError in error-map and allow image/heic uploads#299islandbitcoin wants to merge 2 commits intomainfrom
islandbitcoin wants to merge 2 commits intomainfrom
Conversation
Fixes #298 - Add image/heic to ALLOWED_CONTENT_TYPES in storage/index.ts iOS devices return image/heic from the photo picker; backend was rejecting all iOS photo uploads - Add InvalidFileTypeError case to error-map.ts Missing case caused assertUnreachable() to throw a cryptic 'This should never compile' error instead of a user-friendly validation message
StorageError (base class) was also missing from the error map, causing the same assertUnreachable crash when DO_SPACES_BUCKET is not configured on the backend.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #298
Two fixes for the account upgrade ID document upload flow:
Fix 1 — Allow
image/heicuploads (src/services/storage/index.ts)iOS devices (and the iOS simulator via
react-native-image-picker) returnimage/heicas the content type for photos picked from the library. Addedimage/heictoALLOWED_CONTENT_TYPES.Before:
After:
Fix 2 — Map
InvalidFileTypeErrorinerror-map.ts(src/graphql/error-map.ts)InvalidFileTypeErrorwas not in the switch-case, causing it to fall through toassertUnreachable()which threw:Now maps to
ValidationInternalErrorwith the existing descriptive message from the error class (Invalid file type: X. Allowed: ...).Testing
Found during manual testing of PR #400 (
feat/business-account) account upgrade flow on iOS simulator. Uploading an ID document from the photo library now succeeds instead of returning a cryptic ApolloError.