Skip to content

[Bug]: invalid route auth short form reports 'must be true' instead of the bad field #702

Closed

Description

@jimhoyd

Runtime revision and environment

origin/main at bedd85f (and the #572 quota branch). Node, validateProject/urlcode validate.

Minimal reproduction

routes:
  /api/items:
    redirect: {url: https://example.test/}
    auth: {bearer: {scopes: [items.read], quota: {requests: 0, window: 60}}}

(with extensions.auth declared). The same happens for any invalid key in the object form, for example auth: {freshWithinSeconds: 0} or auth: {roles: [member]}.

Relevant output

Invalid configuration at route /api/items, auth (const): must be true
pointer: /routes/~1api~1items/auth

routes.*.auth is oneOf: [{const: true}, {$ref: routeAuth}] in schemas/urlcode.schema.json, and validateDocument (packages/core/src/config.ts) reports validate.errors[0], which is the const: true branch. The deeper error (/routes/~1api~1items/auth/bearer/quota/requests must be >= 1) is in the error list but never shown. test/extensions.test.ts:249 currently asserts the must be true message for auth: {roles: [...]}.

Possible fix: when the first error is part of a failed oneOf/anyOf and the value is an object, report the deepest error. Another option is an if/then/else on type instead of oneOf.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions