Skip to content

fix(api): an explicit organization_id field is the organization a write sends - #40

Merged
iAziz786 merged 2 commits into
mainfrom
fix/org-field-wins
Oct 10, 2026
Merged

iAziz786 merged 2 commits into
mainfrom
fix/org-field-wins

Conversation

@iAziz786

Copy link
Copy Markdown
Contributor

Spec: #37
Ticket: #39

What this changes

selfhost api writes now carry exactly one organization_id, and it is the one the caller named.

  • A write with -f organization_id=<org> or -F organization_id=<org> sends that value in the JSON body only. The profile's organization no longer rides along on the query string, which previously won the platform's parameter merge and produced a false 404 ("Project not found") when the named organization differed from the profile's.
  • A write with no explicit organization still carries the profile's organization — in the body only, matching the documented rule that writes carry the organization in the body.
  • Bodies that cannot carry the organization (raw --input bytes, non-object JSON bodies) and body-less GETs keep query-string injection, so those requests stay scoped.
  • GET behavior is unchanged; typed resource commands (projects delete, …) never sent a query copy and are untouched.

Verification

  • cargo test: 245 passed, 0 failed (174 unit + 71 integration across 6 suites).
  • cargo fmt --check: no new drift; only the pre-existing files listed in AGENTS.md are flagged.
  • cargo clippy --all-targets: clean, no warnings.

Wire-level tests pin the request shapes, including the reported false-404 shape:

  • DELETE /api/v1/platform/projects/prj_1 with -f organization_id=org_other sends the bare path (no query copy) and a body carrying org_other; the profile's organization appears nowhere.
  • GET with the field keeps it on the query string, one occurrence.
  • --input and non-object bodies keep the organization on the query string.

Closes #37
Closes #39

…te sends

A write whose JSON body named the organization also had the profile's
organization appended to the query string, and the platform's parameter
merge let the query copy win, so -f organization_id=<other> was silently
ignored. The query copy is now dropped for object-body writes and an
organization_id named as a field, on the endpoint query, or in the body
suppresses injection everywhere; raw --input and non-object bodies keep the
query injection so scoped calls still resolve an organization.
@iAziz786
iAziz786 marked this pull request as ready for review October 10, 2026 06:55
@iAziz786
iAziz786 merged commit 992dc99 into main Oct 10, 2026
1 check passed
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.

An explicit organization_id field is the organization a write sends -f organization_id=… is ignored on write verbs: the profile organization wins

1 participant