Refuse a blank grant ref or Bot on revoke, like grant does - #499
Merged
davidmckayv merged 3 commits intoSep 12, 2026
Merged
Conversation
Ayush7614
requested review from
MikeRyanDev,
davidmckayv,
guidovizoso,
mxmzb and
tylerslaton
as code owners
September 12, 2026 12:16
# Conflicts: # CHANGELOG.md # server/tests/plugin-grants-validation.test.ts
davidmckayv
previously approved these changes
Sep 12, 2026
davidmckayv
left a comment
Contributor
There was a problem hiding this comment.
Verified: bug reproduced against main, fix confirmed, tests pass, CI green.
# Conflicts: # CHANGELOG.md
davidmckayv
approved these changes
Sep 12, 2026
davidmckayv
left a comment
Contributor
There was a problem hiding this comment.
Bug reproduced against main, fix verified, tests pass; rebase was CHANGELOG-only on validated substance.
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.
What this changes
Fixes #495. The twin-endpoint inconsistency on the same file:
DELETE /api/plugins/grantscheckedif (!kind || !ref || !agentId). Query params are always strings and" "is truthy, so?ref=%20%20skipped the 400, deleted zero rows by exact match, still wrote aplugin_revokedaudit row naming whitespace, and answered200 {ok:true}.POST /grantsalready requirestypeof === "string" && .trim()with"A kind, a ref and a Bot are required.". DELETE requires the same now and acts on the trimmed values, so surrounding whitespace on a real ref/Bot still revokes what the caller meant.Where it runs
Stateless request validation in the server process. Same 400 on every replica.
Postgres is already there and is the default answer to all of the above: nothing here needs it.
Boundary and audit
enablementRefusalordering is untouched.Changelog
CHANGELOG.mdunderUnreleased: grant revoke validation entry.Proof
bun test server/tests/plugin-grants-validation.test.ts: 16 pass (6 existing POST grants + 4 existing call + 5 new DELETE refusal cases incl. whitespace ref/agentId and missing params + 1 valid revoke proving trimmed values still delete).bun test server/tests/plugin-grants-validation.test.ts server/tests/plugin-routes.test.ts: 31 pass, 0 fail.bunx biome format+bunx biome lint --error-on-warningson touched files: clean.bunx tsc --noEmit -p server/tsconfig.json: only the 3 pre-existingcopilot.tsmissing-module errors, identical on clean upstream main; nothing in touched files.