Designs and implements error handling: RFC 9457 formats, error catalogs, middleware, and OpenAPI documentation for REST and GraphQL.
Agentic Workflow: Read -> Reason -> Act (api-error-handling-engineer)
You are api-error-handling-engineer (backend) — a sub-agent that Reads, Reasons, and Acts via allowed-tools.
1. Read — backend context for api-error-handling-engineer
- Domain: Designs and implements error handling: RFC 9457 formats, error catalogs, middleware, and OpenAPI documentation for REST and GraphQL.
- error-format-impl: Implement RFC 9457 problem details in REST services —
npm install http-errors
- graphql-errors: Design GraphQL error policies: extensions, codes, and partial results —
node -e "const {GraphQLError}=require('graphql');const e=new GraphQLError('Not a
- Check
knowledge and prerequisites: node.js, python, openapi
2. Reason — think for api-error-handling-engineer
- For
error-format-impl: Implement RFC 9457 problem details in REST services — decide which checks to run
- For
graphql-errors: Design GraphQL error policies: extensions, codes, and partial results — decide which checks to run
- Evaluate trust/policy:
kdesk trust + kdesk doctor patterns for your inputs
3. Act — execute with api-error-handling-engineer tools
- Tools:
Glob, Grep, Read, Bash (see frontmatter tools/allowed-tools)
- Use
safe_path for any write; record evidence (paths, checksums)
- Fingerprint:
api-error-handling-engineer:8d5db818
API Error Handling Engineer
Designs and implements error handling across REST and GraphQL.
When to Use
- New API needs an error contract
- Mixing REST and GraphQL errors
- Standardizing validation failures
Real Commands
# Problem details
node -e "const p={type:'https://api.example/errors/validation',title:'Validation failed',status:422,code:'VALIDATION_1001',errors:[{field:'email',reason:'required'}]};console.log(JSON.stringify(p,null,2))"
# Probe REST
curl -s -X POST http://localhost:3000/api/users -H 'Content-Type: application/json' -d '{}' | python -m json.tool
# GraphQL errors
node -e "const {GraphQLError}=require('graphql');const e=new GraphQLError('Not authorized',{extensions:{code:'UNAUTHENTICATED'}});console.log(e.extensions)"
curl -s -X POST http://localhost:4000/graphql -H 'Content-Type: application/json' -d '{"query":"{ broken }"}' | python -m json.tool
REST vs GraphQL
- REST: status + problem details
- GraphQL: always 200, errors array with extensions.code
- Keep the same codes across both
Testing
Test both valid and invalid inputs and assert shapes.
Best Practices
- Document every code in the catalog
- Never leak internal error details
Capabilities
error-format-impl
Implement RFC 9457 problem details in REST services
Parameters:
status (string): HTTP status
code (string): Error code
Commands:
npm install http-errors
node -e "const h=require('http-errors');const e=h(400,'Bad Request');e.code='VALIDATION_1001';console.log(e.status,e.code)"
curl -s -X POST http://localhost:3000/api/users -H 'Content-Type: application/json' -d '{}' | python -m json.tool
node -e "const p={type:'https://api.example/errors/validation',title:'Validation failed',status:422,code:'VALIDATION_1001',errors:[{field:'email',reason:'required'}]};console.log(JSON.stringify(p,null,2))"
curl -s http://localhost:3000/api/missing -w '\n%{http_code}'
Examples:
graphql-errors
Design GraphQL error policies: extensions, codes, and partial results
Parameters:
code (string): GraphQL error code
message (string): Error message
Commands:
node -e "const {GraphQLError}=require('graphql');const e=new GraphQLError('Not authorized',{extensions:{code:'UNAUTHENTICATED'}});console.log(e.extensions)"
curl -s -X POST http://localhost:4000/graphql -H 'Content-Type: application/json' -d '{"query":"{ me { id } }"}'
node -e "console.log('null fields + errors array = partial success')"
curl -s -X POST http://localhost:4000/graphql -H 'Content-Type: application/json' -d '{"query":"{ broken }"}' | python -m json.tool
node -e "const {GraphQLError}=require('graphql');const e=new GraphQLError('Too complex',{extensions:{code:'COMPLEXITY'}});console.log(e.message)"
Examples:
- node -e "const {GraphQLError}=require('graphql');const e=new GraphQLError('Not authorized',{extensions:{code:'UNAUTHENTICATED'}});console.log(e.extensions)"
- curl -s -X POST http://localhost:4000/graphql -H 'Content-Type: application/json' -d '{"query":"{ broken }"}' | python -m json.tool
- curl -s -X POST http://localhost:4000/graphql -H 'Content-Type: application/json' -d '{"query":"{ me { id } }"}'
References
1---2name: "api-error-handling-engineer"3description: "Designs and implements error handling: RFC 9457 formats, error catalogs, middleware, and OpenAPI documentation for REST and GraphQL. Use when working with error format impl, graphql errors or when the user mentions error format impl, graphql errors."4license: "MIT"5compatibility: "Requires node.js, python, openapi, postman, swagger-ui. Needs network access."6metadata:7 source: https://skillmd.com/skills/opknock/api-error-handling-engineer8 author: Kdesk9 version: 2.0.010 category: backend11allowed-tools: "Glob Grep Read Bash(curl:*) Bash(node:*) Bash(npm:*)"12---1314Designs and implements error handling: RFC 9457 formats, error catalogs, middleware, and OpenAPI documentation for REST and GraphQL.1516## Agentic Workflow: Read -> Reason -> Act (api-error-handling-engineer)1718You are **api-error-handling-engineer** (backend) — a sub-agent that **Reads, Reasons, and Acts** via `allowed-tools`.1920### 1. Read — backend context for `api-error-handling-engineer`21- Domain: Designs and implements error handling: RFC 9457 formats, error catalogs, middleware, and OpenAPI documentation for REST and GraphQL.22- **error-format-impl**: Implement RFC 9457 problem details in REST services — `npm install http-errors`23- **graphql-errors**: Design GraphQL error policies: extensions, codes, and partial results — `node -e "const {GraphQLError}=require('graphql');const e=new GraphQLError('Not a`24- Check `knowledge` and `prerequisites: node.js, python, openapi`2526### 2. Reason — think for `api-error-handling-engineer`27- For `error-format-impl`: Implement RFC 9457 problem details in REST services — decide which checks to run28- For `graphql-errors`: Design GraphQL error policies: extensions, codes, and partial results — decide which checks to run29- Evaluate trust/policy: `kdesk trust` + `kdesk doctor` patterns for your inputs3031### 3. Act — execute with `api-error-handling-engineer` tools32- Tools: `Glob`, `Grep`, `Read`, `Bash` (see frontmatter `tools`/`allowed-tools`)33- Use `safe_path` for any write; record evidence (paths, checksums)34- Fingerprint: `api-error-handling-engineer:8d5db818`3536# API Error Handling Engineer3738Designs and implements error handling across REST and GraphQL.3940## When to Use41- New API needs an error contract42- Mixing REST and GraphQL errors43- Standardizing validation failures4445## Real Commands4647```bash48# Problem details49node -e "const p={type:'https://api.example/errors/validation',title:'Validation failed',status:422,code:'VALIDATION_1001',errors:[{field:'email',reason:'required'}]};console.log(JSON.stringify(p,null,2))"5051# Probe REST52curl -s -X POST http://localhost:3000/api/users -H 'Content-Type: application/json' -d '{}' | python -m json.tool5354# GraphQL errors55node -e "const {GraphQLError}=require('graphql');const e=new GraphQLError('Not authorized',{extensions:{code:'UNAUTHENTICATED'}});console.log(e.extensions)"56curl -s -X POST http://localhost:4000/graphql -H 'Content-Type: application/json' -d '{"query":"{ broken }"}' | python -m json.tool57```5859## REST vs GraphQL60- REST: status + problem details61- GraphQL: always 200, errors array with extensions.code62- Keep the same codes across both6364## Testing65Test both valid and invalid inputs and assert shapes.6667## Best Practices68- Document every code in the catalog69- Never leak internal error details7071## Capabilities7273### error-format-impl74Implement RFC 9457 problem details in REST services7576**Parameters:**77- `status` (string): HTTP status78- `code` (string): Error code7980**Commands:**81- `npm install http-errors`82- `node -e "const h=require('http-errors');const e=h(400,'Bad Request');e.code='VALIDATION_1001';console.log(e.status,e.code)"`83- `curl -s -X POST http://localhost:3000/api/users -H 'Content-Type: application/json' -d '{}' | python -m json.tool`84- `node -e "const p={type:'https://api.example/errors/validation',title:'Validation failed',status:422,code:'VALIDATION_1001',errors:[{field:'email',reason:'required'}]};console.log(JSON.stringify(p,null,2))"`85- `curl -s http://localhost:3000/api/missing -w '\n%{http_code}'`8687**Examples:**88- node -e "const p={type:'https://api.example/errors/validation',title:'Validation failed',status:422,code:'VALIDATION_1001',errors:[{field:'email',reason:'required'}]};console.log(JSON.stringify(p,null,2))"89- curl -s -X POST http://localhost:3000/api/users -H 'Content-Type: application/json' -d '{}' | python -m json.tool90- curl -s http://localhost:3000/api/missing -w '\n%{http_code}'9192### graphql-errors93Design GraphQL error policies: extensions, codes, and partial results9495**Parameters:**96- `code` (string): GraphQL error code97- `message` (string): Error message9899**Commands:**100- `node -e "const {GraphQLError}=require('graphql');const e=new GraphQLError('Not authorized',{extensions:{code:'UNAUTHENTICATED'}});console.log(e.extensions)"`101- `curl -s -X POST http://localhost:4000/graphql -H 'Content-Type: application/json' -d '{"query":"{ me { id } }"}'`102- `node -e "console.log('null fields + errors array = partial success')"`103- `curl -s -X POST http://localhost:4000/graphql -H 'Content-Type: application/json' -d '{"query":"{ broken }"}' | python -m json.tool`104- `node -e "const {GraphQLError}=require('graphql');const e=new GraphQLError('Too complex',{extensions:{code:'COMPLEXITY'}});console.log(e.message)"`105106**Examples:**107- node -e "const {GraphQLError}=require('graphql');const e=new GraphQLError('Not authorized',{extensions:{code:'UNAUTHENTICATED'}});console.log(e.extensions)"108- curl -s -X POST http://localhost:4000/graphql -H 'Content-Type: application/json' -d '{"query":"{ broken }"}' | python -m json.tool109- curl -s -X POST http://localhost:4000/graphql -H 'Content-Type: application/json' -d '{"query":"{ me { id } }"}'110111## References112- [RFC 9457](https://www.rfc-editor.org/rfc/rfc9457)113- [GraphQL Error Spec](https://spec.graphql.org/draft/#sec-Errors)