Skip to content

super.post() throws uncaught exception when POSTing to resource without trailing slash #678

Description

@kriszyp

When a Resource class exported by harper/redirects (or similar) is POSTed to without a trailing slash, super.post() throws an unhandled exception:

Cannot read properties of undefined (reading 'query')

With a trailing slash but a random path segment (e.g. /redirects/hi), the error changes slightly:

Cannot read properties of null (reading 'query')

Context

  • Trailing slash IS required per design and this is documented — it's not a missing-feature issue.
  • The problem is the unhandled exception surfacing to super.post() rather than a clean 404 or 405.
  • Was silently working in 4.3; broke in 4.5 in a way that erodes confidence.

Ask

Catch the missing-trailing-slash case in the Resource request dispatch and return an appropriate HTTP error (404 or 405 with a clear message) rather than letting the Cannot read properties of undefined exception propagate.


🤖 Filed by Claude on behalf of Kris.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:rest-apiREST API, resources, routingbugSomething isn't workingfrom-jiraMigrated or originated from a Jira ticket

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions