ObjectStackObjectStack

Errors

Errors protocol schemas

Standardized Error Codes Protocol

Implements P0 requirement for ObjectStack kernel. Provides consistent, machine-readable error codes across the platform.

Features:

  • Categorized error codes (validation, authentication, authorization, etc.)
  • HTTP status code mapping
  • Localization support
  • Retry guidance

Industry alignment: Google Cloud Errors, AWS Error Codes, Stripe API Errors

Source: packages/spec/src/api/errors.zod.ts

TypeScript Usage

import { EnhancedApiErrorSchema, ErrorCategory, ErrorResponseSchema, FieldErrorSchema, FieldErrorCode, RetryStrategy, StandardErrorCode } from '@objectstack/spec/api';
import type { EnhancedApiError, ErrorCategory, ErrorResponse, FieldError, FieldErrorCode, RetryStrategy, StandardErrorCode } from '@objectstack/spec/api';

// Validate data
const result = EnhancedApiErrorSchema.parse(data);

EnhancedApiError

Properties

PropertyTypeRequiredDescription
codeEnum<'VALIDATION_ERROR' | 'INVALID_FIELD' | 'MISSING_REQUIRED_FIELD' | 'INVALID_FORMAT' | 'VALUE_TOO_LONG' | 'VALUE_TOO_SHORT' | 'VALUE_OUT_OF_RANGE' | … +46 more>Machine-readable error code
messagestringHuman-readable error message
categoryEnum<'validation' | 'authentication' | 'authorization' | 'not_found' | 'conflict' | 'rate_limit' | 'server' | 'external' | 'maintenance'>optionalError category
httpStatusnumberoptionalHTTP status code
retryablebooleanWhether the request can be retried
retryStrategyEnum<'no_retry' | 'retry_immediate' | 'retry_backoff' | 'retry_after'>optionalRecommended retry strategy
retryAfternumberoptionalSeconds to wait before retrying
detailsanyoptionalAdditional error context
fields{ field: string; code: Enum<'required' | 'invalid_type' | 'invalid_shape' | 'unknown_field' | … +24 more>; message: string; label?: string; … }[]optionalOne entry per offending value
fieldErrorsneveroptional[REMOVED] EnhancedApiError.fieldErrors was renamed to fields in @objectstack/spec 17 (ADR-0114 D4, #3977) — the array is unchanged, only the property name. Every producer already emitted fields; fieldErrors was declared and never emitted, so a reader keying on it was reading a field no server sent.
timestampstringoptionalWhen the error occurred
requestIdstringoptionalRequest ID for tracking
traceIdstringoptionalDistributed trace ID
documentationstringoptionalURL to error documentation
helpTextstringoptionalSuggested actions to resolve the error

Allowed Values: EnhancedApiError.code

  • VALIDATION_ERROR
  • INVALID_FIELD
  • MISSING_REQUIRED_FIELD
  • INVALID_FORMAT
  • VALUE_TOO_LONG
  • VALUE_TOO_SHORT
  • VALUE_OUT_OF_RANGE
  • INVALID_REFERENCE
  • DUPLICATE_VALUE
  • INVALID_QUERY
  • INVALID_FILTER
  • INVALID_SORT
  • MAX_RECORDS_EXCEEDED
  • UNAUTHENTICATED
  • INVALID_CREDENTIALS
  • EXPIRED_TOKEN
  • INVALID_TOKEN
  • SESSION_EXPIRED
  • MFA_REQUIRED
  • EMAIL_NOT_VERIFIED
  • PERMISSION_DENIED
  • INSUFFICIENT_PRIVILEGES
  • FIELD_NOT_ACCESSIBLE
  • RECORD_NOT_ACCESSIBLE
  • LICENSE_REQUIRED
  • IP_RESTRICTED
  • TIME_RESTRICTED
  • RESOURCE_NOT_FOUND
  • OBJECT_NOT_FOUND
  • RECORD_NOT_FOUND
  • FIELD_NOT_FOUND
  • ENDPOINT_NOT_FOUND
  • RESOURCE_CONFLICT
  • CONCURRENT_MODIFICATION
  • DELETE_RESTRICTED
  • DUPLICATE_RECORD
  • LOCK_CONFLICT
  • METHOD_NOT_ALLOWED
  • PRECONDITION_REQUIRED
  • RATE_LIMIT_EXCEEDED
  • QUOTA_EXCEEDED
  • CONCURRENT_LIMIT_EXCEEDED
  • INTERNAL_ERROR
  • DATABASE_ERROR
  • TIMEOUT
  • SERVICE_UNAVAILABLE
  • NOT_IMPLEMENTED
  • EXTERNAL_SERVICE_ERROR
  • INTEGRATION_ERROR
  • WEBHOOK_DELIVERY_FAILED
  • BATCH_PARTIAL_FAILURE
  • BATCH_COMPLETE_FAILURE
  • TRANSACTION_FAILED

ErrorCategory

Allowed Values

  • validation
  • authentication
  • authorization
  • not_found
  • conflict
  • rate_limit
  • server
  • external
  • maintenance

ErrorResponse

Properties

PropertyTypeRequiredDescription
successfalseAlways false for error responses
error{ code: Enum<'VALIDATION_ERROR' | 'INVALID_FIELD' | 'MISSING_REQUIRED_FIELD' | … +50 more>; message: string; category?: Enum<'validation' | 'authentication' | 'authorization' | 'not_found' | 'conflict' | … +4 more>; httpStatus?: number; … }Error details
meta{ timestamp?: string; requestId?: string; traceId?: string }optionalResponse metadata

FieldError

Properties

PropertyTypeRequiredDescription
fieldstringField path (supports dot notation)
codeEnum<'required' | 'invalid_type' | 'invalid_shape' | 'unknown_field' | 'invalid_boolean' | 'invalid_number' | 'invalid_date' | 'invalid_time' | 'invalid_email' | … +19 more>Which constraint the value violated (field-level catalog, ADR-0114)
messagestringHuman-readable error message, rendered in the caller’s locale
labelstringoptionalField display label in the caller’s locale
valueanyoptionalThe invalid value that was provided
constraintRecord<string, any>optionalThe constraint that was violated, as discrete values (e.g. { maxLength: 512, actual: 3000 })

Allowed Values: FieldError.code

  • required
  • invalid_type
  • invalid_shape
  • unknown_field
  • invalid_boolean
  • invalid_number
  • invalid_date
  • invalid_time
  • invalid_email
  • invalid_url
  • invalid_phone
  • invalid_json
  • invalid_format
  • min_length
  • max_length
  • min_value
  • max_value
  • max_scale
  • min_items
  • max_items
  • invalid_option
  • invalid_value
  • reference_not_found
  • reference_ambiguous
  • rule_violation
  • json_schema_violation
  • invalid_initial_state
  • invalid_transition

FieldErrorCode

Allowed Values

  • required
  • invalid_type
  • invalid_shape
  • unknown_field
  • invalid_boolean
  • invalid_number
  • invalid_date
  • invalid_time
  • invalid_email
  • invalid_url
  • invalid_phone
  • invalid_json
  • invalid_format
  • min_length
  • max_length
  • min_value
  • max_value
  • max_scale
  • min_items
  • max_items
  • invalid_option
  • invalid_value
  • reference_not_found
  • reference_ambiguous
  • rule_violation
  • json_schema_violation
  • invalid_initial_state
  • invalid_transition

RetryStrategy

Allowed Values

  • no_retry
  • retry_immediate
  • retry_backoff
  • retry_after

StandardErrorCode

Allowed Values

  • VALIDATION_ERROR
  • INVALID_FIELD
  • MISSING_REQUIRED_FIELD
  • INVALID_FORMAT
  • VALUE_TOO_LONG
  • VALUE_TOO_SHORT
  • VALUE_OUT_OF_RANGE
  • INVALID_REFERENCE
  • DUPLICATE_VALUE
  • INVALID_QUERY
  • INVALID_FILTER
  • INVALID_SORT
  • MAX_RECORDS_EXCEEDED
  • UNAUTHENTICATED
  • INVALID_CREDENTIALS
  • EXPIRED_TOKEN
  • INVALID_TOKEN
  • SESSION_EXPIRED
  • MFA_REQUIRED
  • EMAIL_NOT_VERIFIED
  • PERMISSION_DENIED
  • INSUFFICIENT_PRIVILEGES
  • FIELD_NOT_ACCESSIBLE
  • RECORD_NOT_ACCESSIBLE
  • LICENSE_REQUIRED
  • IP_RESTRICTED
  • TIME_RESTRICTED
  • RESOURCE_NOT_FOUND
  • OBJECT_NOT_FOUND
  • RECORD_NOT_FOUND
  • FIELD_NOT_FOUND
  • ENDPOINT_NOT_FOUND
  • RESOURCE_CONFLICT
  • CONCURRENT_MODIFICATION
  • DELETE_RESTRICTED
  • DUPLICATE_RECORD
  • LOCK_CONFLICT
  • METHOD_NOT_ALLOWED
  • PRECONDITION_REQUIRED
  • RATE_LIMIT_EXCEEDED
  • QUOTA_EXCEEDED
  • CONCURRENT_LIMIT_EXCEEDED
  • INTERNAL_ERROR
  • DATABASE_ERROR
  • TIMEOUT
  • SERVICE_UNAVAILABLE
  • NOT_IMPLEMENTED
  • EXTERNAL_SERVICE_ERROR
  • INTEGRATION_ERROR
  • WEBHOOK_DELIVERY_FAILED
  • BATCH_PARTIAL_FAILURE
  • BATCH_COMPLETE_FAILURE
  • TRANSACTION_FAILED

On this page