Skip to content

Requirements PATCH: explicit null clears parent_id (issue #30) - #82

Merged
abbyfluoroethane merged 1 commit into
develfrom
claude/issue-30-parent-id-clear
Aug 16, 2026
Merged

Requirements PATCH: explicit null clears parent_id (issue #30)#82
abbyfluoroethane merged 1 commit into
develfrom
claude/issue-30-parent-id-clear

Conversation

@abbyfluoroethane

Copy link
Copy Markdown
Member

Closes the last gap in #30.

87cf6ad (merged in #56) made rationale, category, verification_method, tbr_owner_id and tbr_due clearable via model_fields_set, but left parent_id on the None-skip path — even though it is nullable by design ("level-0 roots have no parent"). So the original symptom survived in that one field:

PATCH {"rationale": null}   → cleared
PATCH {"parent_id": null}   → 200 OK, parent_id unchanged

Reproduced against a running instance before fixing: a child requirement can never be promoted back to a level-0 root, and the API reports success while ignoring the edit.

The change

parent_id joins the clearable set. Two deliberate non-changes:

  • level is not adjusted. level and parent_id are already independent PATCH fields (you can change either alone today), and re-levelling on a parent clear would be a surprise the caller didn't ask for. The caller sets level in the same PATCH if it should change.
  • The validation guard stays if data.parent_id is not None. Clearing has no parent to look up, so skipping the existence/self-parent checks is correct.

Verification

New test asserts the clear works, survives reload, and that omitting the field leaves it alone. Confirmed non-vacuous — it fails with assert 1 is None when the one-line change is reverted. Full suite 1054 passed / 1 skipped; ruff check src/ and ruff format --check src/ clean.

Note the two F841s and one format diff ruff reports under tests/ are pre-existing and untouched here; CI only covers src/.

🤖 Generated with Claude Code

https://claude.ai/code/session_014jPbhRuDUZLie159gQxTDZ

87cf6ad made five nullable fields clearable but left parent_id on the
None-skip path, so `{"parent_id": null}` returned 200 and silently kept
the parent — the exact symptom #30 was filed for, in the one nullable
field the fix missed. A child requirement could never be promoted back
to a level-0 root; the API reported success while ignoring the edit.

parent_id joins the clearable set. level is deliberately not adjusted:
the two are already independent PATCH fields, and re-levelling a subtree
on a parent clear would be a surprise the caller didn't ask for.

The existing validation guard still only runs for a non-null parent_id,
which is what clearing wants — there is no parent to look up.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014jPbhRuDUZLie159gQxTDZ
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.

1 participant