Skip to content

backend/fix: Making detected imageType optional#1301

Open
Brajmohank1 wants to merge 1 commit into
mainfrom
making-detected-imageType-optional
Open

backend/fix: Making detected imageType optional#1301
Brajmohank1 wants to merge 1 commit into
mainfrom
making-detected-imageType-optional

Conversation

@Brajmohank1
Copy link
Copy Markdown

@Brajmohank1 Brajmohank1 commented May 21, 2026

Type of Change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring
  • Dependency updates

Description

Additional Changes

  • This PR modifies the database schema (database migration added)
  • This PR modifies dhall configs/environment variables

Motivation and Context

How did you test it?

Checklist

  • I formatted the code and addressed linter errors ./dev/format-all-files.sh
  • I reviewed submitted code
  • I added unit tests for my changes where possible
  • I added a CHANGELOG entry if applicable

Summary by CodeRabbit

  • Bug Fixes
    • Document verification now preserves unknown image types instead of defaulting to a specific type; when the system cannot determine a document type, the detected-image type will be omitted (represented as empty/null) so downstream consumers can handle unknowns explicitly.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 21, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: cbcb7570-3368-467a-9831-00a5ed06ce37

📥 Commits

Reviewing files that changed from the base of the PR and between 963556e and 091bba7.

📒 Files selected for processing (2)
  • lib/mobility-core/src/Kernel/External/Verification/Interface/Idfy.hs
  • lib/mobility-core/src/Kernel/External/Verification/Interface/Types.hs

Walkthrough

This change makes image type detection optional: DetectedImage.imageType is now Maybe ImageType, and getImageType returns Just <ImageType> for known identifiers or Nothing for unrecognized document types.

Changes

Optional image type detection

Layer / File(s) Summary
Optional image type detection
lib/mobility-core/src/Kernel/External/Verification/Interface/Types.hs, lib/mobility-core/src/Kernel/External/Verification/Interface/Idfy.hs
DetectedImage.imageType field changes from required ImageType to optional Maybe ImageType. getImageType function returns Just <ImageType> for known document identifiers and Nothing for unknown strings, removing the fallback to VehicleRegistrationCertificate.

🎯 2 (Simple) | ⏱️ ~8 minutes

A rabbit hops through the verification code,
Making image types optional—less of a load,
Unknown docs now vanish to Nothing so clean,
Type safety strengthens in the code stream,
No more defaults when the path's not been seen! 🐇✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: making the detected imageType optional in the codebase.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch making-detected-imageType-optional

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
lib/mobility-core/src/Kernel/External/Verification/Interface/Idfy.hs (1)

293-301: 💤 Low value

Consider logging unknown doc types instead of silently dropping.

The new Nothing fallback is correct and a clear improvement over silently misclassifying as VehicleRegistrationCertificate. However, since the upstream Idfy API may introduce new detected_doc_type codes over time, silently mapping them to Nothing makes it hard to detect coverage gaps. Consider emitting a warning log (or metric) in mkValidateImageResp when getImageType returns Nothing for a non-empty detected_doc_type so unsupported types surface in observability.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@lib/mobility-core/src/Kernel/External/Verification/Interface/Idfy.hs` around
lines 293 - 301, The fallback in getImageType currently returns Nothing for
unknown detected_doc_type values; update mkValidateImageResp to emit a warning
(or metric) whenever getImageType returns Nothing but the original
detected_doc_type string is non-empty so unsupported upstream types are
observable; locate where mkValidateImageResp calls getImageType, check the
source field (e.g., detected_doc_type) and add a processLogger/warn/metrics call
including the raw detected_doc_type and any relevant context (request id/user
id) so operators can detect coverage gaps.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@lib/mobility-core/src/Kernel/External/Verification/Interface/Idfy.hs`:
- Around line 293-301: The fallback in getImageType currently returns Nothing
for unknown detected_doc_type values; update mkValidateImageResp to emit a
warning (or metric) whenever getImageType returns Nothing but the original
detected_doc_type string is non-empty so unsupported upstream types are
observable; locate where mkValidateImageResp calls getImageType, check the
source field (e.g., detected_doc_type) and add a processLogger/warn/metrics call
including the raw detected_doc_type and any relevant context (request id/user
id) so operators can detect coverage gaps.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 35193c9d-91de-4923-80f2-112a30efb16a

📥 Commits

Reviewing files that changed from the base of the PR and between 6b1b641 and 963556e.

📒 Files selected for processing (2)
  • lib/mobility-core/src/Kernel/External/Verification/Interface/Idfy.hs
  • lib/mobility-core/src/Kernel/External/Verification/Interface/Types.hs

@Brajmohank1 Brajmohank1 force-pushed the making-detected-imageType-optional branch from 963556e to 091bba7 Compare May 22, 2026 10:45
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.

1 participant