Skip to content

feat: schema validation middleware and audit log utility - #564

Closed
ZacLou wants to merge 2 commits into
StableRoute-Org:mainfrom
ZacLou:validation-audit
Closed

ZacLou wants to merge 2 commits into
StableRoute-Org:mainfrom
ZacLou:validation-audit

Conversation

@ZacLou

@ZacLou ZacLou commented Sep 14, 2026

Copy link
Copy Markdown

Summary

Implements schema-based request validation and append-only audit logging for state-changing operations.

Changes

Schema Validation Middleware (#555)

  • validateSchema() middleware with type, bounds, length, pattern, and allowedValues checks
  • Returns 400 with detailed error messages per field

Audit Log Utility (#557)

  • auditLog() helper wrapping recordEvent with graceful error handling
  • Ensures audit logging never breaks main application flow

Testing

  • 9 tests covering all validation rules and audit events

Closes #555, #557

…r /api/v1/pairs

The route list endpoint used offset pagination where the cursor
was merely a base64-encoded integer offset. This caused rows to
be skipped or duplicated when pairs were registered between page
fetches.

Changes:
- Add parseCursorKey: decodes opaque base64url-encoded sort keys
- Add cursorPaginate: sorts by cursorKey and filters by key position
  instead of using offset-based array slicing
- Update GET /api/v1/pairs to use cursor pagination with the pair
  key (source::destination) as the stable cursor

Edge cases covered by tests:
- First page then next: no gaps or duplicates
- Rows inserted mid-scan: no skipped/duplicated existing rows
- End of list: nextCursor is null
- Invalid cursor: returns 400 invalid_request
- Page size clamps to max (500)

Closes StableRoute-Org#553
- validateSchema() middleware with type, bounds, length, pattern checks
- auditLog() helper for append-only state-change auditing
- 9 tests covering validation rules and audit events

Closes StableRoute-Org#555, StableRoute-Org#557
@ZacLou

ZacLou commented Sep 27, 2026

Copy link
Copy Markdown
Author

Closing this to keep the queue tidy.

@ZacLou ZacLou closed this Sep 27, 2026
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.

schema-based request validation with bounds for routing endpoints

1 participant