feat(spp_api_v2): auto-assign system_id to registrants for API addressability#162
feat(spp_api_v2): auto-assign system_id to registrants for API addressability#162
Conversation
|
You have used all of your free Bugbot PR reviews. To receive reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial. |
There was a problem hiding this comment.
Code Review
This pull request updates the to_api_schema and membership_to_response methods to return None and log a warning instead of raising a ValidationError when external identifiers are missing. Corresponding null checks have been added to the search routers and the get_groups service. Review feedback highlights the need for more robust identifier selection to prevent malformed API references and warns of potential crashes in single-resource endpoints that have not yet been updated to handle the new None return value.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## 19.0 #162 +/- ##
==========================================
+ Coverage 71.36% 71.63% +0.26%
==========================================
Files 932 935 +3
Lines 54792 55413 +621
==========================================
+ Hits 39101 39693 +592
- Misses 15691 15720 +29
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
… records without reg_ids
…ership reference preference
…eal IDs in references
… valid identifier
f3177c2 to
e4fc7bc
Compare
…pdate tests for auto-assignment
Summary
The web UI allows creating registrants without identity documents, but the V2 API requires at least one identifier to address records. Records without identifiers were invisible to the API — they couldn't be searched, referenced in memberships, or synced to external systems like DataCollect.
This PR auto-generates a system-level registry ID (UUID) for every registrant at creation time. This is not an identity document — it's an internal addressability key, similar to a partner ID but exposed safely through the API without leaking sequential database IDs.
Changes
system_idunderurn:openspp:vocab:id-type— distinguishes system IDs from real identity documents (national_id, passport, etc.)res.partner.createoverride generates a UUID registry ID for new registrantsmembership_utils.pyusesid_type_id.uri(full code URI) instead ofnamespace_urifor identifier lookupto_api_schemareturnsNonewith a warning for records that somehow still lack identifiers (safety net)Context
Confirmed with OpenSPP team: identity documents being required in the API but not in the web UI is a bug. The
NO database IDs exposeddesign constraint into_api_schemameans we cannot usepartner.idas a fallback — hence the UUID-based approach using the existing vocabulary/registry system.Test plan
system_ididentifier🤖 Generated with Claude Code