Skip to content

fix(spp_api_v2): skip records without identifiers instead of crashing#162

Open
pmigueld wants to merge 6 commits into19.0from
fix/api-v2-skip-records-without-identifiers
Open

fix(spp_api_v2): skip records without identifiers instead of crashing#162
pmigueld wants to merge 6 commits into19.0from
fix/api-v2-skip-records-without-identifiers

Conversation

@pmigueld
Copy link
Copy Markdown

OpenSPP API breaks upon serializing data that has missing identity documents. This is due to the web UI having it optional while the API schema requires it. I propose to align the schema with the the web UI and have it be optional as well.

@pmigueld pmigueld requested a review from jeremi April 15, 2026 06:33
@cursor
Copy link
Copy Markdown

cursor bot commented Apr 15, 2026

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.

Copy link
Copy Markdown

@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 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.

Comment thread spp_api_v2/services/membership_utils.py Outdated
Comment thread spp_api_v2/services/membership_utils.py Outdated
Comment thread spp_api_v2/services/group_service.py
Comment thread spp_api_v2/services/individual_service.py
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 15, 2026

Codecov Report

❌ Patch coverage is 76.19048% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 71.50%. Comparing base (5a7544e) to head (f3177c2).

Files with missing lines Patch % Lines
spp_api_v2/services/membership_utils.py 55.55% 4 Missing ⚠️
spp_api_v2/routers/program_membership.py 50.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             19.0     #162      +/-   ##
==========================================
+ Coverage   71.19%   71.50%   +0.30%     
==========================================
  Files         931      933       +2     
  Lines       54694    55467     +773     
==========================================
+ Hits        38942    39664     +722     
- Misses      15752    15803      +51     
Flag Coverage Δ
spp_api_v2 80.23% <76.19%> (+0.12%) ⬆️
spp_api_v2_change_request 66.85% <ø> (ø)
spp_api_v2_cycles 71.12% <ø> (ø)
spp_api_v2_data 64.41% <ø> (ø)
spp_api_v2_entitlements 70.19% <ø> (ø)
spp_api_v2_gis 71.52% <ø> (ø)
spp_api_v2_products 66.27% <ø> (ø)
spp_api_v2_service_points 70.94% <ø> (ø)
spp_api_v2_simulation 71.12% <ø> (ø)
spp_api_v2_vocabulary 57.26% <ø> (ø)
spp_banking ?
spp_base_common 90.26% <ø> (ø)
spp_base_setting ?
spp_dci_client_dr 55.87% <ø> (ø)
spp_dci_client_ibr 60.17% <ø> (ø)
spp_dci_demo 69.23% <ø> (ø)
spp_dci_server 35.68% <ø> (ø)
spp_farmer_registry_demo 54.01% <ø> (+0.62%) ⬆️
spp_mis_demo_v2 74.20% <ø> (+4.18%) ⬆️
spp_programs 62.17% <ø> (ø)
spp_security 66.66% <ø> (ø)
spp_starter_social_registry 0.00% <ø> (ø)

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

Files with missing lines Coverage Δ
spp_api_v2/routers/bulk.py 100.00% <ø> (ø)
spp_api_v2/routers/filter.py 29.91% <ø> (ø)
spp_api_v2/routers/group.py 74.36% <100.00%> (+0.42%) ⬆️
spp_api_v2/routers/individual.py 77.54% <100.00%> (+0.24%) ⬆️
spp_api_v2/services/group_service.py 85.03% <100.00%> (+0.24%) ⬆️
spp_api_v2/services/individual_service.py 71.93% <100.00%> (+0.18%) ⬆️
spp_api_v2/routers/program_membership.py 74.30% <50.00%> (+1.06%) ⬆️
spp_api_v2/services/membership_utils.py 84.00% <55.55%> (-6.91%) ⬇️

... and 32 files with indirect coverage changes

🚀 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.

@pmigueld pmigueld marked this pull request as draft April 15, 2026 06:42
@pmigueld pmigueld marked this pull request as ready for review April 15, 2026 09:01
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