You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(policy): handle unmapped HTTP methods in methodToAction (HEAD, OPTIONS) (#3158)
* fix(policy): handle unmapped HTTP methods in methodToAction
Add explicit `head: 'read'` and `options: 'read'` mappings so HEAD and
OPTIONS requests are routed to the correct CASL action instead of
resolving to `undefined`. Add a guard in `isAllowed` that returns 403
for any unmapped method to prevent incorrect authorization decisions.
Closes#3137
* fix(tasks): align schema and test with Zod v4 invalid_type message
In Zod v4, passing `error: 'string'` to `z.string()` does not override
the `invalid_type` issue message — the actual output is
'Expected string, received number'. Remove the no-op `error` option from
the Task schema and update the integration test expectation to match.
Add a note to ERRORS.md to prevent the same mistake in future migrations.
* fix(policy): apply Copilot review — 405 for unknown methods, early guard
- Return 405 Method Not Allowed (instead of 403) for unmapped HTTP methods
with a descriptive message to distinguish from permission denials
- Move the action lookup and early-return guard before defineAbilityFor
to avoid unnecessary CASL import and rules evaluation for unsupported methods
- Update unit test expectation from 403 to 405 accordingly
* fix(tasks): correct Zod v4 invalid_type message in test and ERRORS.md
Local node_modules had Zod v3 (3.25.76) masking the real v4 behavior.
Zod v4 (^4.3.6 from package.json) produces
'Invalid input: expected string, received number' — not the v3 message
'Expected string, received number'. Update the test expectation and the
ERRORS.md entry to match the actual Zod v4 output.
* test(policy): assert response body content in 405 test
Following Copilot review: add assertions on message and description fields
in the 405 response to catch regressions if the error message format changes.
Copy file name to clipboardExpand all lines: ERRORS.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,3 +15,4 @@ Use this file as a compact memory of recurring AI mistakes.
15
15
-[2026-02-22] tests: never patch code to pass a test -> if a test is wrong, fix the test; if logic needs refactoring, refactor it
16
16
-[2026-02-23] pr skill: stopping after `gh pr ready` -> always enter the monitor loop (wait CI → 3min grace → read feedback → iterate) until stop condition is met
17
17
-[2026-02-23] pr skill: skipping issue creation when none found -> always create a GitHub issue before opening a PR (`gh issue create --web` or via CLI)
18
+
-[2026-02-23] zod v4: z.string({ error: 'msg' }) does NOT override invalid_type message -> Zod v4 produces 'Invalid input: expected string, received number'; update test expectations accordingly and remove the no-op error option
0 commit comments