problem
Constructs an RFC 9457 compliant Problem Details error payload. Supports both positional shorthand for common errors and map syntax for structured validation errors and custom metadata extensions.
Signatures
Parameters
Positional syntax
Object map syntax
Automatic field derivation
To minimize boilerplate in manifests, problem() automatically derives missing fields:
- Title: If
titleis omitted, the engine uses the canonical HTTP status text forstatus(e.g.404->"Not Found",409->"Conflict"). - Type URI: If
typeis omitted, the title is slugified and appended to the configured URI scheme:- Default:
"urn:hclapi:error:<slug>"(e.g."urn:hclapi:error:not-found"). - If
problem.type_prefixis set inserver {}:problem.type_prefix + "<slug>"(e.g."https://docs.example.com/errors/not-found").
- Default:
- Instance: Defaults to the current request's URL path (
ctx.request.path).
Examples
1. Simple 404 not found response (Positional)
Serialized output:
2. Database constraint collision with custom slug (Positional)
Serialized output:
3. Validation failure with RFC 9457 extensions (Map syntax)
Serialized output:
Errors
- Fails with an evaluation error if
statusis not an integer or if required arguments are missing. - Fails with an evaluation error if a single argument is passed that is not a
mapornumber.