Skip to content

fix(spp_registry): use correct field for id type in validation error#117

Merged
gonzalesedwin1123 merged 1 commit into19.0from
fix/spp-registry-id-validation-attribute-error
Mar 18, 2026
Merged

fix(spp_registry): use correct field for id type in validation error#117
gonzalesedwin1123 merged 1 commit into19.0from
fix/spp-registry-id-validation-attribute-error

Conversation

@gonzalesedwin1123
Copy link
Copy Markdown
Member

Summary

  • Fix AttributeError in spp.registry.id validation constraint caused by accessing .name on spp.vocabulary.code, which has no name field (_rec_name = "display")
  • The ID validation regex check now correctly shows a ValidationError with the ID type label instead of crashing

Test plan

  • Create an spp.registry.id record with an ID type that has id_validation set and provide a value that doesn't match the regex — should show a clean validation error with the ID type name
  • Verify existing flows that create registry IDs with valid values still work normally

spp.vocabulary.code has no `name` field — its _rec_name is `display`.
The validation constraint crashed with AttributeError instead of
showing the intended ValidationError message.
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, 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 spp.registry.id module where an AttributeError would occur during ID validation. By switching the field used to retrieve the ID type's label from name to display, the system now gracefully handles invalid ID inputs, providing clear and informative validation errors to the user instead of crashing.

Highlights

  • Bug Fix: Resolved an AttributeError in the spp.registry.id validation constraint by correcting the field accessed from .name to .display.
  • Improved Error Handling: Ensured that ID validation regex checks now correctly display a ValidationError with the appropriate ID type label, preventing application crashes.
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.

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.

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 correctly fixes an AttributeError in the registrant ID validation by using the display field instead of the non-existent name field on the spp.vocabulary.code model. The change is correct and resolves the described bug. I have also added a comment regarding a potential improvement to the validation trigger logic for better robustness.

_(
"The provided %(id_type)s ID '%(value)s' is invalid.",
id_type=rec.id_type_id.name,
id_type=rec.id_type_id.display,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

While this change to use rec.id_type_id.display is correct, the validation method it belongs to has a potential weakness. The _onchange_id_validation method is only triggered when the value field changes, but the validation logic also depends on id_type_id. This means that if id_type_id is changed, the validation for the existing value is not re-evaluated in the UI. This could be improved by also triggering the validation on id_type_id changes.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 18, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.32%. Comparing base (1a91296) to head (e101a68).
⚠️ Report is 6 commits behind head on 19.0.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             19.0     #117      +/-   ##
==========================================
+ Coverage   70.14%   70.32%   +0.17%     
==========================================
  Files         739      756      +17     
  Lines       43997    44863     +866     
==========================================
+ Hits        30863    31549     +686     
- Misses      13134    13314     +180     
Flag Coverage Δ
spp_analytics 93.13% <ø> (ø)
spp_api_v2 79.96% <ø> (ø)
spp_api_v2_change_request 66.66% <ø> (ø)
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_approval 50.29% <ø> (ø)
spp_area 79.26% <ø> (?)
spp_area_hdx 81.43% <ø> (ø)
spp_audit 64.19% <ø> (ø)
spp_banking 80.00% <ø> (?)
spp_base_common 90.26% <ø> (ø)
spp_base_setting 50.00% <ø> (?)
spp_programs 45.51% <ø> (ø)
spp_security 66.66% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.
see 17 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.

@gonzalesedwin1123 gonzalesedwin1123 marked this pull request as ready for review March 18, 2026 08:44
@gonzalesedwin1123 gonzalesedwin1123 merged commit 5fba270 into 19.0 Mar 18, 2026
35 checks passed
@gonzalesedwin1123 gonzalesedwin1123 deleted the fix/spp-registry-id-validation-attribute-error branch March 18, 2026 08:47
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