Skip to content

Refuse a malformed limit on GET /api/admin/audit-events with 400 - #512

Merged
davidmckayv merged 3 commits into
CopilotKit:mainfrom
Ayush7614:fix/audit-events-limit-validation
Sep 13, 2026
Merged

Refuse a malformed limit on GET /api/admin/audit-events with 400#512
davidmckayv merged 3 commits into
CopilotKit:mainfrom
Ayush7614:fix/audit-events-limit-validation

Conversation

@Ayush7614

Copy link
Copy Markdown
Contributor

auditQueryFromUrl matched digits but fell back to 50 on anything else, so ?limit=abc, ?limit=12abc, ?limit=3.9 and ?limit=-5 silently returned the default page while ?from=garbage on the same endpoint answered 400. Channels and people already answer 400 through parsePageLimit.

This reuses parsePageLimit(url limit, 100) and throws AuditQueryError on !ok, so the route's existing catch answers 400 naming the parameter. Absent/blank still means the default 50; digits still clamp 1..100. Also refreshes the paging.ts docstring, which described the old audit fallback.

Tests: new server/tests/audit-limit.test.ts (16 cases: defaults, boundaries, clamp, padding, 6 malformed shapes throwing + route 400 without reaching the store, valid limit reaching the store). Verified: audit cursor + limit + audit suite — 27 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 bc7b328 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