fix: use dedicated struct for identity mapping request#359
Closed
leifj wants to merge 2 commits into
Closed
Conversation
1ff26ca to
84af15e
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adjusts the POST /api/v1/identity/mapping request model so the endpoint no longer reuses model.Identity (which requires authentic_source_person_id), and extends the datastore lookup to optionally narrow matches using additional identity fields when provided.
Changes:
- Introduces
IdentityMappingIdentityas a dedicated request struct for the identity mapping endpoint and converts it tomodel.Identityinternally. - Adds optional identity fields to the MongoDB query filter to narrow ID mapping matches when those fields are present.
- Updates the handler request type for
/identity/mappingto use the new struct.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| internal/apigw/apiv1/handlers_datastore.go | Adds a dedicated request identity type for /identity/mapping and maps it into model.Identity for datastore lookup. |
| internal/apigw/db/methods_vc_datastore.go | Extends the ID mapping MongoDB filter with optional identity fields for more specific matching. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
The IdentityMapping endpoint reused model.Identity which requires authentic_source_person_id - but that field is the output of this endpoint, not an input. Create IdentityMappingIdentity with only the fields needed for lookup: schema, family_name, given_name, birth_date.
84af15e to
3068ef4
Compare
|
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.



The
POST /api/v1/identity/mappingendpoint reusedmodel.Identitywhich marksauthentic_source_person_idandschemaas required via validation tags. However,authentic_source_person_idis the output of this endpoint — requiring it in the request is contradictory.This creates a dedicated
IdentityMappingIdentitystruct for the mapping request with:schema,family_name,given_name,birth_datebirth_place,nationality,personal_administrative_number,birth_family_name,birth_given_name,sex,email_address,mobile_phone_number,issuing_authority,issuing_countryThe handler converts
IdentityMappingIdentity→model.Identityinternally before passing to the datastore.The MongoDB query now uses
$elemMatchto ensure all identity predicates match the same array element (preventing cross-element false positives), and uses$allfor nationality matching. Optional fields are included in the filter only when provided.Regenerated swagger docs to reflect the new request type.
Reported by SKV during integration testing — the documented example (without
authentic_source_person_id) was returning a validation error.