Skip to content

[Request]: Declarative validation for JSON request bodies and path parameter patterns #254

Closed

Description

@jimhoyd

Tried: validate the JSON body (title 1-200 chars string, optional description, boolean completed) and the path id.
Expected: declare it in YAML.
Got: only JSON syntax, media type and size are declarative. Body rules (~25 lines) and the id format check live in code; path parameter schemas accept minLength/maxLength but no pattern/format, so a UUID check is hand-written.
Suggestion: a JSON Schema subset for request.body returning a structured 400/422, and pattern/format on parameter schemas.
Evidence: an A/B benchmark on URLCode 0.4.1 with Sonnet 5 agents building the same Todo app from the repo docs. Run 1 (benchmark Agent B, no authoring skill, no browser check) and run 2 (session "Todo application with URLCode", authoring skill loaded, tightened prompt) hit this independently. n=1 each; single small app, so treat frequency as anecdotal. The Agent A control (no URLCode) needed 2 shell calls and 0 dependencies for the same app.
Not verified: interaction with sandboxed routes' snapshot/limits.

Activity

  1. added
    enhancement
    on Sep 20, 2026
  2. added
    needs-decision
    ai-first
    on Sep 20, 2026
  3. jimhoyd commented on Sep 20, 2026

    @jimhoyd
    CollaboratorAuthor

    Decision: build both pieces now: a declarative JSON-Schema subset for request.body (structured 400/422 on failure) and pattern/format on parameter schemas.

    Guardrails for the implementer:

    • Parameter format comes from a small fixed allowlist (uuid first); no author-supplied regex needed for it.
    • Free-form pattern runs author regexes on every request in the host process, so ReDoS applies. Require a length cap on both pattern and input, and a linear-time or pre-checked regex. Reject patterns that fail the check at validation time, before activation.
    • Parameter schemas are compiled with Ajv in src/router.ts; reuse that path rather than adding a second validator.

    Not verified: interaction with sandboxed routes' snapshot and limits (as the issue notes). Cover it with a test before landing. Update the specification and npm run docs:reference, with an executable example, in the same PR. This is a prerequisite for the store extension in #253.

  4. removed
    needs-decision
    on Sep 20, 2026
  5. added
    in-progress
    on Sep 20, 2026
  6. jimhoyd commented on Sep 20, 2026

    @jimhoyd
    CollaboratorAuthor

    Progress: implementation started by an agent against the maintainer decision on this issue; a PR will be linked here when it opens.

  7. jimhoyd commented on Sep 20, 2026

    @jimhoyd
    CollaboratorAuthor

    Progress: PR #306 opened (draft): request.body.schema (422 on failure), parameter format: uuid and a restricted pattern, with docs and examples/body-validation. Sandboxed-route and real-Worker behavior are not verified.

  8. added
    important
    on Sep 20, 2026
  9. jimhoyd commented on Sep 20, 2026

    @jimhoyd
    CollaboratorAuthor

    Progress: taking over draft PR #306 to finish it.

  10. added 3 commits that reference this issue on Sep 20, 2026
  11. removed
    in-progress
    on Sep 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    ai-firstenhancementimportant

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions