Skip to content

Refuse a malformed limit on POST /api/computers/policy-dry-run with 400 - #511

Merged
davidmckayv merged 3 commits into
CopilotKit:mainfrom
Ayush7614:fix/policy-dry-run-limit-validation
Sep 13, 2026
Merged

Refuse a malformed limit on POST /api/computers/policy-dry-run with 400#511
davidmckayv merged 3 commits into
CopilotKit:mainfrom
Ayush7614:fix/policy-dry-run-limit-validation

Conversation

@Ayush7614

Copy link
Copy Markdown
Contributor

The dry-run read typeof limit === "number" ? limit : 200 and clamped, so string/null/bool silently became 200, Infinity silently became 500, fractions were truncated, and NaN travelled into auditReader.list as NaN. A what-if answered from the wrong slice of history is worse than no answer.

Absent still means the default 200; a present limit must now be a whole number 1..500, else 400 limit must be a whole number between 1 and 500. Policy validation still runs first.

Tests: new server/tests/computer-policy-dry-run-limit.test.ts (17 cases: default window, boundaries 1/200/500, 12 malformed shapes never reaching the reader, malformed policy precedence). Verified: policy route + dry-run engine + new file — 31 pass.

@davidmckayv davidmckayv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deep-reviewed clean (validation, no secret leak, fail-closed, agrees with existing layers). CI green.

@davidmckayv
davidmckayv merged commit 505ef93 into CopilotKit:main Sep 13, 2026
15 checks 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.

2 participants