Skip to content

Errors

Error handling, error codes, multiple errors, and source pointers


An error object describes a single error:

{
"code": "INVALID_ARGUMENTS",
"message": "Customer ID must be a positive integer",
"retryable": false,
"source": {
"pointer": "/call/arguments/customer_id"
},
"details": {
"expected": "positive integer",
"received": -1
}
}
FieldTypeRequiredDescription
codestringYesMachine-readable error code. MUST be SCREAMING_SNAKE_CASE.
messagestringYesHuman-readable error description.
retryablebooleanYesWhether the client SHOULD retry this request.
sourceobjectNoLocation of the error cause.
detailsobjectNoAdditional structured error context.

Responses always use the errors field (plural array):

{
"protocol": { "name": "mesh", "version": "0.1.0" },
"id": "req_123",
"result": null,
"errors": [
{
"code": "INVALID_ARGUMENTS",
"message": "Email is required",
"retryable": false,
"source": { "pointer": "/call/arguments/email" }
}
]
}
  • The errors array MUST contain at least one error
  • Even single errors use the errors array format

The source object pinpoints where the error originated using JSON Pointer (RFC 6901):

Points to the request field that caused the error:

{
"source": {
"pointer": "/call/arguments/customer_id"
}
}

Common pointer patterns:

PointerDescription
/call/arguments/fieldTop-level argument
/call/arguments/items/0/skuArray element field
/call/arguments/address/cityNested object field
/extensions/0/options/valueExtension option field
/context/trace_idContext field

For parse errors, indicates byte offset:

{
"source": {
"position": 142
}
}
  • pointer MUST use JSON Pointer syntax (RFC 6901)
  • pointer MUST be relative to the request root
  • position MUST be a zero-indexed byte offset
  • A source object MUST contain pointer OR position, not both

Errors in the Mesh envelope or protocol handling:

CodeRetryableDescription
PARSE_ERRORNoRequest is not valid JSON
INVALID_REQUESTNoRequest structure violates protocol
INVALID_PROTOCOL_VERSIONNoUnsupported protocol version

Errors in function resolution:

CodeRetryableDescription
FUNCTION_NOT_FOUNDNoUnknown function name
VERSION_NOT_FOUNDNoUnknown version for the function
FUNCTION_DISABLEDYesFunction temporarily disabled
INVALID_ARGUMENTSNoArguments failed validation
SCHEMA_VALIDATION_FAILEDNoArguments failed schema validation
EXTENSION_NOT_SUPPORTEDNoRequested extension not supported
CodeRetryableDescription
UNAUTHORIZEDNoAuthentication required or failed
FORBIDDENNoAuthenticated but not permitted
CodeRetryableDescription
NOT_FOUNDNoRequested resource does not exist
CONFLICTNoOperation conflicts with current state
GONENoResource existed but was deleted
CodeRetryableDescription
DEADLINE_EXCEEDEDYesRequest exceeded deadline
RATE_LIMITEDYesToo many requests
INTERNAL_ERRORYesUnexpected server error
UNAVAILABLEYesService temporarily unavailable
DEPENDENCY_ERRORYesDownstream service failed
CodeRetryableDescription
IDEMPOTENCY_CONFLICTNoIdempotency key reused with different arguments
IDEMPOTENCY_PROCESSINGYesPrevious request with same key still processing
CodeRetryableDescription
ASYNC_OPERATION_NOT_FOUNDNoUnknown operation ID
ASYNC_OPERATION_FAILEDNoAsync operation failed permanently
ASYNC_CANNOT_CANCELNoOperation cannot be cancelled (completed or not cancellable)
CodeRetryableDescription
BATCH_FAILEDNoAtomic batch failed (one or more operations failed)
BATCH_TOO_LARGENoToo many operations or payload too large
BATCH_TIMEOUTYesBatch execution exceeded timeout

Applications MAY define additional error codes.

Custom codes SHOULD:

  • Use SCREAMING_SNAKE_CASE
  • Be prefixed with application/domain identifier
  • Be documented for API consumers

Example:

{
"code": "ORDERS_INVENTORY_INSUFFICIENT",
"message": "Not enough inventory for SKU WIDGET-01",
"retryable": false,
"details": {
"sku": "WIDGET-01",
"requested": 10,
"available": 3
}
}

The retryable field indicates whether clients SHOULD retry:

Transient failures that MAY succeed on retry:

  • DEADLINE_EXCEEDED — Try with longer deadline or later
  • RATE_LIMITED — Try after backoff
  • INTERNAL_ERROR — Transient server issue
  • UNAVAILABLE — Service temporarily down
  • DEPENDENCY_ERROR — Downstream recovered

Permanent failures that MUST NOT succeed on retry:

  • INVALID_ARGUMENTS — Fix the arguments first
  • NOT_FOUND — Resource doesn’t exist
  • FORBIDDEN — Permission denied
  • CONFLICT — State has changed

Clients MUST:

  • Implement exponential backoff for retryable errors
  • Respect Retry-After hints if provided in details
  • Set a maximum retry count
  • NOT retry non-retryable errors

The details object provides structured context beyond the message:

{
"code": "INVALID_ARGUMENTS",
"message": "Validation failed",
"retryable": false,
"source": { "pointer": "/call/arguments/email" },
"details": {
"constraint": "email_format",
"value": "not-an-email"
}
}
{
"code": "RATE_LIMITED",
"message": "Too many requests",
"retryable": true,
"details": {
"limit": 100,
"window": { "value": 1, "unit": "minute" },
"retry_after": { "value": 5, "unit": "second" }
}
}
{
"code": "DEPENDENCY_ERROR",
"message": "Payment service unavailable",
"retryable": true,
"details": {
"dependency": "payments-api",
"dependency_error": "connection timeout"
}
}

{
"protocol": { "name": "mesh", "version": "0.1.0" },
"id": "req_123",
"result": null,
"errors": [
{
"code": "INVALID_ARGUMENTS",
"message": "Customer ID is required",
"retryable": false,
"source": {
"pointer": "/call/arguments/customer_id"
}
}
]
}
{
"protocol": { "name": "mesh", "version": "0.1.0" },
"id": "req_456",
"result": null,
"errors": [
{
"code": "INVALID_ARGUMENTS",
"message": "Email format is invalid",
"retryable": false,
"source": { "pointer": "/call/arguments/email" },
"details": { "constraint": "email_format" }
},
{
"code": "INVALID_ARGUMENTS",
"message": "Quantity must be at least 1",
"retryable": false,
"source": { "pointer": "/call/arguments/items/0/quantity" },
"details": { "constraint": "min", "min": 1, "actual": 0 }
},
{
"code": "INVALID_ARGUMENTS",
"message": "Unknown SKU",
"retryable": false,
"source": { "pointer": "/call/arguments/items/1/sku" },
"details": { "sku": "UNKNOWN-123" }
}
]
}
{
"protocol": { "name": "mesh", "version": "0.1.0" },
"id": null,
"result": null,
"errors": [
{
"code": "PARSE_ERROR",
"message": "Invalid JSON: unexpected token at position 89",
"retryable": false,
"source": {
"position": 89
}
}
]
}
{
"protocol": { "name": "mesh", "version": "0.1.0" },
"id": "req_789",
"result": null,
"errors": [
{
"code": "RATE_LIMITED",
"message": "Rate limit exceeded",
"retryable": true,
"details": {
"limit": 1000,
"window": { "value": 1, "unit": "hour" },
"retry_after": { "value": 2, "unit": "minute" }
}
}
]
}