Skip to content

fix: map InvalidFileTypeError in error-map and allow image/heic uploads#299

Open
islandbitcoin wants to merge 2 commits intomainfrom
fix/id-upload-file-type-error
Open

fix: map InvalidFileTypeError in error-map and allow image/heic uploads#299
islandbitcoin wants to merge 2 commits intomainfrom
fix/id-upload-file-type-error

Conversation

@islandbitcoin
Copy link
Contributor

Summary

Fixes #298

Two fixes for the account upgrade ID document upload flow:

Fix 1 — Allow image/heic uploads (src/services/storage/index.ts)

iOS devices (and the iOS simulator via react-native-image-picker) return image/heic as the content type for photos picked from the library. Added image/heic to ALLOWED_CONTENT_TYPES.

Before:

const ALLOWED_CONTENT_TYPES = ["image/jpeg", "image/png", "image/webp"] as const

After:

const ALLOWED_CONTENT_TYPES = ["image/jpeg", "image/png", "image/webp", "image/heic"] as const

Fix 2 — Map InvalidFileTypeError in error-map.ts (src/graphql/error-map.ts)

InvalidFileTypeError was not in the switch-case, causing it to fall through to assertUnreachable() which threw:

Error: This should never compile with InvalidFileTypeError

Now maps to ValidationInternalError with 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.

forge0x added 2 commits March 18, 2026 21:41
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.
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.

InvalidFileTypeError not mapped in GraphQL error-map + HEIC not in allowed content types

2 participants