Use consistent HTTP methods for updates and invite replies - #166
Open
martsokha wants to merge 1 commit into
Open
Use consistent HTTP methods for updates and invite replies#166martsokha wants to merge 1 commit into
martsokha wants to merge 1 commit into
Conversation
Two API-method inconsistencies surfaced by an audit: - Connection, policy, and webhook updates were registered as PUT, but their DTOs are all-optional and the handlers do partial merges (omitted fields left unchanged) — PATCH semantics. Switch them to PATCH so all update endpoints agree (the other seven already used PATCH). - The two invite-reply endpoints diverged: replying by id returned 200 + Invite while replying by code returned 201 + Member, even though both accept paths create a membership. Align reply-by-id with reply-by-code: 201 + Member on accept, 200 + None on decline, so the same action reports the same result regardless of path. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Summary
An audit of HTTP methods across the handlers found two inconsistencies; this fixes both.
1. Update endpoints: PUT → PATCH
Connection, policy, and webhook updates were registered as PUT, but their request DTOs are entirely
Optionfields and the handlers do partial merges (..Default::default(), omitted field = unchanged) — i.e. PATCH semantics mislabeled as PUT. The other seven update endpoints (account, member, file, pipeline, workspace, notification settings, api token) already use PATCH. Switched these three so all ten agree.2. Invite replies: consistent status + body
The two invite-reply endpoints diverged even though both accept-paths create a membership:
reply_to_invite(by id): returned200 + Invitereply_to_invite_code(by code): returned201 + MemberAligned
reply_to_invitewithreply_to_invite_code:201 + Memberon accept,200 + Noneon decline. The same action now reports the same result regardless of which path a client uses, and the accept path no longer hides the created membership behind a200 + Invite.Notes
Reviewed but deliberately left unchanged (defensible, not bugs):
POST /members/leave/(a distinct self-service action, DELETE is reserved for admin-remove which forbids self-removal), and the action POSTs (test webhook, redact run, generate code, detect run).Breaking for clients calling the old
PUTupdate routes or relying on the old invite-reply shape — acceptable pre-release.Verification
cargo clippy --all-targets --all-features --workspace -- -D warnings✅cargo +nightly fmt --all -- --check✅RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --all-features --workspace✅cargo test --all-features -p nvisy-server✅🤖 Generated with Claude Code