Repository navigation
Validate statement query parameter names and combinations - #590
thomasturrell wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
🔵 Needs a closer look
The change alters HTTP request routing and introduces validation that depends on subtle Spring MVC @ModelAttribute/handler-matching ordering, which I verified by reasoning but could not execute, so a human should confirm before approval.
0 open findings
What changed in this PR
This PR hardens query-parameter handling for the sample xAPI Learning Record Store's statements endpoint. Previously, unknown or incorrectly capitalised parameters and invalid single-statement/filter combinations could fall through to the general list handler and incorrectly return 200. The change adds an @ModelAttribute pre-handler validator that rejects such requests with 400 before the service is invoked, corrects the @GetMapping routing exclusions, and introduces a dedicated voidedStatementId handler returning 501 instead of an unrelated statement list.
Changes:
- Added
validateParametersto allow-list parameter names per HTTP method and reject combiningstatementId/voidedStatementIdwith anything other thanformat/attachments(and reject combining the two identifiers). - Fixed the GET routing conditions (
getStatement,getStatementsSince,getStatements) and added agetVoidedStatementhandler that explicitly returns501. - Added parameterised MVC regression tests (35 name/combination cases plus representation/list/HEAD/write cases) asserting no service interactions on rejection, and documented scope/limitations in the README.
| File | Description |
|---|---|
| samples/xapi-server/src/main/java/dev/learning/xapi/samples/xapiserver/StatementController.java | Adds method-aware parameter validation, a voidedStatementId 501 handler, and corrected GET routing conditions. |
| samples/xapi-server/src/test/java/dev/learning/xapi/samples/xapiserver/StatementsControllerTest.java | Adds parameterised and single-case regression tests for name/combination rejection and permitted parameters. |
| samples/xapi-server/README.md | Documents the parameter validation rules and remaining filtering/formatting limitations. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|



Statement requests currently accept unknown or incorrectly capitalised parameters, and invalid single-statement/filter combinations can fall through to the general list handler and return 200. Reject these requests with 400 before calling the service.
Reviewed xAPI 1.0.3 Communication requirements 2.1.3.s2.b1–b2 and 3.2.s3.b7–b8.
Validation on revision 494c5b5:
Local clean verify was blocked by Maven Central name resolution and the available Java 17 runtime; executable validation was completed in Java 25 CI.