Skip to content

Out-of-range perPage/page returns "Unexpected error." instead of the documented clear error #715

Description

@ddeboer

Summary

buildGraphQLSchema documents that an out-of-range perPage "is rejected with a clear error instead of reaching the engine". It is rejected, but the client sees Unexpected error. with INTERNAL_SERVER_ERROR, so there is nothing to act on.

Reproduction

search-api-server:0.7.0, maxPerPage at its default of 100:

{ creativeWorks(perPage: 101) { pagination { total } } }
{ "message": "Unexpected error.",
  "extensions": { "code": "INTERNAL_SERVER_ERROR" } }

Identical for perPage: -1 and page: 0. perPage: 0 is accepted, correctly – it is the facet-only query.

Likely cause

The bound check throws a plain Error, and Yoga masks anything that is not a GraphQLError behind Unexpected error. to avoid leaking internals. Throwing a GraphQLError (optionally extensions.code: 'BAD_USER_INPUT') would surface it unmasked, since the message is deliberately client-facing.

Why it matters

The bound is not discoverable: it is not in the SDL, and introspection shows only perPage: Int. A client that guesses too high gets a message indistinguishable from a server fault – the natural next step is to retry, or to report an outage. Naming the limit in the error ("perPage must be between 0 and 100") makes it self-correcting.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions