Skip to content

🐛 server: select valid document when multiple same-class ids exist#706

Merged
cruzdanilo merged 1 commit intomainfrom
ids
Jan 30, 2026
Merged

🐛 server: select valid document when multiple same-class ids exist#706
cruzdanilo merged 1 commit intomainfrom
ids

Conversation

@mainqueg
Copy link
Contributor

@mainqueg mainqueg commented Jan 30, 2026


Open with Devin

Summary by CodeRabbit

  • Bug Fixes
    • Fixed document selection to properly choose the correct document when multiple documents with the same class ID exist.

✏️ Tip: You can customize this high-level summary in your review settings.

@changeset-bot
Copy link

changeset-bot bot commented Jan 30, 2026

🦋 Changeset detected

Latest commit: 9be9db9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@exactly/server Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@gemini-code-assist
Copy link

Summary of Changes

Hello @mainqueg, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a critical bug in the server's document evaluation logic. Previously, when multiple identity documents shared the same classification, the system might fail to identify the most complete and valid document. The changes ensure that the server now correctly processes all relevant documents of a given class, guaranteeing that the appropriate document is selected for further processing, thereby improving the robustness of the identity verification workflow.

Highlights

  • Bug Fix: Document Selection Logic: Resolved an issue where the system might incorrectly select an incomplete document when multiple documents of the same class were present, even if a complete document existed.
  • Improved Document Validation: The getValidDocumentForManteca function now iterates through all documents of a given class to find a valid one, ensuring that a complete document is prioritized over an incomplete one.
  • New Test Cases: Added comprehensive test cases to persona.test.ts to cover scenarios involving multiple documents of the same class, verifying that the correct and complete document is selected.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@coderabbitai
Copy link

coderabbitai bot commented Jan 30, 2026

Walkthrough

This PR fixes document selection logic when multiple ID documents of the same class exist. The implementation now filters all documents matching an ID class and validates photo presence before selection. Comprehensive test coverage verifies the corrected behavior.

Changes

Cohort / File(s) Summary
Changeset
.changeset/ripe-oranges-vanish.md
Patch version bump for @exactly/server documenting bugfix for selecting valid documents when multiple same-class IDs exist.
Document Selection Logic
server/utils/persona.ts
Modified getDocument to encode documentId with encodeURIComponent; updated getValidDocumentForManteca to filter all documents by id_class and validate photo presence before selection instead of early exit.
Test Coverage
server/test/utils/persona.test.ts
Added 133 lines of new test cases verifying Manteca document selection when multiple same-class documents exist, confirming complete document selection and fetch invocation counts in two test scenarios.

Estimated Code Review Effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly Related PRs

Suggested Reviewers

  • nfmelendez
  • cruzdanilo
🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly relates to the core change: handling selection of valid documents when multiple documents share the same class ID, which is the exact bug fix addressed in the changeset.

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch ids

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

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 3 additional flags.

Open in Devin Review

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request addresses a bug by ensuring all documents of a given class are considered for selection, rather than just the first. However, it introduces a potential Server-Side Request Forgery (SSRF) vulnerability due to unsanitized id_document_id values being used in API calls, which could lead to path traversal on the Persona API. Additionally, a performance improvement for fetching document details in parallel has been suggested.

@sentry
Copy link

sentry bot commented Jan 30, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 64.60%. Comparing base (d27bae2) to head (9be9db9).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #706      +/-   ##
==========================================
- Coverage   65.42%   64.60%   -0.83%     
==========================================
  Files         173      173              
  Lines        5539     5385     -154     
  Branches     1567     1505      -62     
==========================================
- Hits         3624     3479     -145     
+ Misses       1730     1726       -4     
+ Partials      185      180       -5     
Flag Coverage Δ
e2e 43.12% <ø> (-20.30%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@cruzdanilo cruzdanilo merged commit 9be9db9 into main Jan 30, 2026
14 of 15 checks passed
@cruzdanilo cruzdanilo deleted the ids branch January 30, 2026 22:31
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