Repository navigation
Conversation
PATCH /v2/user-policies/{id} now accepts policy_id. Supplied alone, it
points the saved policy at that v2 policy and clears legacy_policy_id,
which no longer describes the saved content. Supplied with
legacy_policy_id, both are stored, and policy_id must be the v2 copy of
that v1 policy when one exists, exactly as creation decides. The policy
must exist in the row's country. The row keeps its ID, owner, name and
creation time, so an edited reform keeps the ID that reports link to.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PATCH /v2/user-households/{id} now accepts household_id, with the same
rules as a saved policy's policy_id: supplied alone, it points the saved
household at that v2 household and clears legacy_household_id; supplied
with legacy_household_id, both are stored, and household_id must be the
v2 copy of that v1 household when one exists. The household must exist
in the row's country, and the row keeps its ID, owner, name and creation
time. Without this, editing a saved household changed its ID.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A household repoint can now fail with a reference conflict, and the household route tests sent only DELETE requests through the failure mapping. Send a repointing PATCH through it and pin each refusal's status: 400 for a country or reference conflict, 404 for a missing household or saved household, and 422 for a missing v1 household. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #4005 +/- ##
===========================================
+ Coverage 50.12% 87.95% +37.82%
===========================================
Files 243 259 +16
Lines 14726 16169 +1443
Branches 2343 2636 +293
===========================================
+ Hits 7382 14222 +6840
+ Misses 6721 1275 -5446
- Partials 623 672 +49 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This branch was successfully deployed
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.
Fixes #4004
Summary
PATCH /v2/user-policies/{association_id}acceptspolicy_id, andPATCH /v2/user-households/{association_id}acceptshousehold_id. A saved reform or household can then point at a newly created v2 policy or household while keeping its ID, owner, name and creation time, so reports that link to a saved reform keep working after it is edited.policy_idis supplied alone, it clearslegacy_policy_id, because the v1 policy no longer describes what is saved; the same applies tohousehold_idandlegacy_household_id. If both are supplied, the v1 reference must exist in v1 (422) and both are stored; the v2 reference must equal the v2 copy of that v1 record when one exists (400 otherwise). These are the same rules creation already applies. Alegacy_*_idsupplied alone behaves as before: the v2 reference is re-resolved from the copy mapping, or cleared.null(422).Migration notes
policyandhousehold(user associations). The response contracts are unchanged; only the PATCH request bodies gain one optional field each, and the generated migration contracts do not change.Environment variables
None. The change reads no environment variables and touches no workflow, image or infrastructure.
What this PR waits for
Only review. It has no schema change, no migration and no deployment dependency. It is the bottom of a stack of Public API PRs for the v2 metadata, regions and saved-items work; the PRs above it build on this branch.
Testing
Each commit was written test-first:
79dd19602(saved policies): 9 tests failed first (policy_idrefused as an extra field); then the four user-association test files passed (44), andtests/unit/v2,tests/contractandtests/unit/test_migration_contract_artifacts.pypassed (1,060).e3d176fbb(saved households): 8 tests failed first (household_idrefused); then 70 passed in the four files, 1,065 in the broad suite. Against a disposable PostgreSQL 17 database:alembic -c alembic-v2.ini upgrade head,reconcile_v2_privileges.py apply --create-missing-rolesandverify, thentests/integration/test_alembic_v2_lifecycle.py,test_v2_user_identity_persistence.pyandtest_v2_privilege_reconciliation.py(25 passed, services running as the runtime role).083820742(review follow-up, tests only): pins the PATCH failure statuses for households. It passed immediately, because the shared failure mapping already returns them; with the conflict status temporarily changed to 409, two cases failed.ruff format --check .,ruff check .,uv run --frozen --extra dev mypy,python scripts/run_quality_guards.py;python scripts/export_migration_contracts.pyleft the generated files unchanged.No inline
# noqasuppressions are added.🤖 Generated with Claude Code