Skip to content

fix(spp_cr_type_assign_program): scope duplicate-assignment conflict to (registrant, program)#208

Merged
gonzalesedwin1123 merged 1 commit into
19.0from
fix/assign-program-cross-registrant-conflict
May 22, 2026
Merged

fix(spp_cr_type_assign_program): scope duplicate-assignment conflict to (registrant, program)#208
gonzalesedwin1123 merged 1 commit into
19.0from
fix/assign-program-cross-registrant-conflict

Conversation

@gonzalesedwin1123
Copy link
Copy Markdown
Member

Summary

  • The duplicate-assignment conflict rule uses scope='custom', so the base conflict domain does not pre-filter by registrant. The hook only narrowed candidates by program_id, so submitting a second CR was blocked whenever any other in-flight assign_program CR targeted the same program — even for a different registrant.
  • Filter candidates by both program_id and registrant_id, matching the rule's intent (and the override's docstring): conflicts trigger only on the same (registrant, program) pair.
  • Add regression test test_f5_two_crs_for_different_registrants_same_program_allowed and bump the module to 19.0.1.0.1.

Test plan

  • ./scripts/test_single_module.sh spp_cr_type_assign_program — 19 passed, 0 failed
  • pre-commit run --files spp_cr_type_assign_program/{__manifest__.py,models/change_request.py,tests/test_assign_program.py} — all hooks pass
  • Manual UI: two CRs for different registrants assigning to the same program — both can now Submit for Approval without the false "blocking conflicts detected" error
  • Existing behavior preserved: same registrant + same program still blocks (test_f2); same registrant + different programs still allowed (test_f3)

…to (registrant, program)

The rule uses scope='custom', so the base conflict domain does not pre-filter
by registrant. The hook only narrowed candidates by program_id, which
incorrectly blocked submitting a CR whenever any other in-flight CR targeted
the same program, even for a different registrant.

Filter candidates by both program_id and registrant_id to match the rule's
intent (and the override's docstring). Add a regression test covering the
different-registrants/same-program case.
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 refines the conflict detection logic for assigning registrants to programs, ensuring that conflicts are only flagged when the same registrant is assigned to the same program. The changes include an update to the _check_custom_conflicts method to filter by registrant ID, improved documentation, and a new test case to verify the logic. Feedback was provided to optimize the filtering logic for better performance through short-circuiting and to include a defensive check for missing detail records.

Comment on lines +48 to +50
return candidates.filtered(
lambda c: c.detail_res_id in matching_detail_ids and c.registrant_id == self.registrant_id
)
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

Consider swapping the conditions in the filtered lambda to leverage short-circuiting. Since candidates may contain many records for different registrants, checking the registrant_id first is more efficient as it avoids the set lookup for non-matching registrants. Additionally, per repository guidelines, defensively filter out any records where the detail record (detail_res_id) is missing to handle edge cases like newly created records.

Suggested change
return candidates.filtered(
lambda c: c.detail_res_id in matching_detail_ids and c.registrant_id == self.registrant_id
)
return candidates.filtered(
lambda c: c.detail_res_id and c.registrant_id == self.registrant_id and c.detail_res_id in matching_detail_ids
)
References
  1. When processing records that should have related detail records, defensively filter out any records where the detail record is missing to handle edge cases like newly created records.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 71.27%. Comparing base (6991217) to head (a8edf53).
⚠️ Report is 3 commits behind head on 19.0.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             19.0     #208      +/-   ##
==========================================
+ Coverage   71.23%   71.27%   +0.03%     
==========================================
  Files         968      976       +8     
  Lines       57634    57736     +102     
==========================================
+ Hits        41057    41150      +93     
- Misses      16577    16586       +9     
Flag Coverage Δ
spp_base_common 90.26% <ø> (ø)
spp_cr_type_assign_program 91.17% <100.00%> (?)
spp_programs 64.84% <ø> (ø)
spp_security 66.66% <ø> (ø)

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

Files with missing lines Coverage Δ
spp_cr_type_assign_program/__manifest__.py 0.00% <ø> (ø)
...pp_cr_type_assign_program/models/change_request.py 94.44% <100.00%> (ø)

... and 6 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 merged commit dcafa51 into 19.0 May 22, 2026
17 of 18 checks passed
@gonzalesedwin1123 gonzalesedwin1123 deleted the fix/assign-program-cross-registrant-conflict branch May 22, 2026 03:54
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