test(store): cover workspace-member paging limit/role/cursor error paths - #237
test(store): cover workspace-member paging limit/role/cursor error paths#237KrasimirKralev wants to merge 1 commit into
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs real behavior proof before merge. Reviewed September 5, 2026, 7:33 AM ET / 11:33 UTC. ClawSweeper reviewWhat this changesAdds six Go tests covering workspace-member paging limits, invalid role filters, and malformed or incompatible cursors. Merge readiness⛔ Blocked before merge - 2 items remain Keep open: current main lacks this focused validation coverage, and no actionable patch defect was found. The supplied test evidence does not satisfy the external-contributor real-behavior proof gate. Priority: P3 Review scores
Verification
How this fits togetherClickClack’s member-directory API passes paging inputs through shared validation helpers before querying SQLite or PostgreSQL. These tests protect the helpers that normalize limits and reject invalid filters and cursors. flowchart TD
A[Member directory request] --> B[HTTP input parsing]
B --> C[Shared paging validation]
T[New regression tests] --> C
C -->|Invalid input| D[Request error]
C -->|Valid input| E[Database member query]
E --> F[Member page and continuation cursor]
Before merge
Agent review detailsSecurityNone. Review metrics
Technical reviewBest possible solution: Keep validation centralized in the shared store helpers and protect its existing contract with these focused regression tests. Do we have a high-confidence way to reproduce the issue? Not applicable: this PR characterizes working validation behavior rather than reporting a runtime defect; the asserted outcomes match current source. Is this the best way to solve the issue? Yes: direct helper tests are a narrow way to cover validation branches without database setup or production changes, and they complement the existing integration tests. AGENTS.md: found, but no applicable review policy affected this item. Codex review notes: model internal, reasoning high; reviewed against fa52084a04bf. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
What Problem This Solves
The workspace-member paging helpers in
apps/api/internal/store/workspace_member_pages.go(NormalizeWorkspaceMemberPageRequest,DecodeWorkspaceMemberCursor) guard the member-list endpoint against bad input: an out-of-range page limit, an unknown role filter, and a malformed or stale pagination cursor. The existingsqlite/postgresListWorkspaceMemberPagesuites exercise these helpers only on the happy path (valid roles, in-range limits, cursors they round-trip themselves), so the input-validation branches — the ones that decide whether a bad request is rejected or silently mishandled — had no coverage and could regress unnoticed.Why This Change Was Made
Adds a focused, characterization-only test file (
workspace_member_pages_test.go, tests-only, no production change) that pins the error/boundary arms the boundary suites cannot reach: zero-limit default, over-max clamp, negative-limit rejection, invalid role-filter rejection, and cursor rejection for bad base64, non-JSON payloads, a wrong schema version, and a missing tie-break user id. The cases are deliberately the ones a normal paging call never produces, so they complement rather than duplicate the existing integration coverage.User Impact
No runtime, API, or behavior change. Operators and API clients gain a regression guard: if a future change weakened the limit clamp or the cursor-validation checks, these tests fail instead of the member-list endpoint quietly accepting a malformed cursor or an unbounded page size.
Evidence
Focused run of the new tests on current
main, then a mutation control proving each test bites its target branch, on Linux (Go 1.27.1):Mutation controls (each applied to
workspace_member_pages.go, test re-run, then reverted): dropping the over-max clamp assignment, disabling the zero-limit default, widening the negative-limit guard, disabling the invalid-role guard, and neutralizing each malformed/stale-cursorreturn— every mutation turned the corresponding test from PASS to FAIL, and the control was restored byte-identical.gofmt -landgo vet ./apps/api/internal/store/are clean.Scope boundary: tests-only (+81/−0, one new file); no production code, dependency, schema, or public-contract change. Allow edits from maintainers is enabled on this branch.
This is an AI-assisted contribution (openclaw contribution cron, account @KrasimirKralev).
Generated by Claude Code