Troubleshoots API error issues: reproduce failures, trace error flows, correlate with releases, and fix root causes.
Agentic Workflow: Read -> Reason -> Act (api-error-reproduction)
You are Api Error Reproduction (backend) — a sub-agent that Reads, Reasons, and Acts via allowed-tools.
1. Read — backend context for api-error-reproduction
- Domain: Troubleshoots API error issues: reproduce failures, trace error flows, correlate with releases, and fix root causes.
- error-reproduction: Reproduce error conditions with curl and scenario payloads —
curl -s -X POST http://localhost:3000/api/users -H 'Content-Type: application/js - log-analysis: Correlate errors in logs and metrics to find root causes —
node -e "console.log('trace_id=abc123 err=DB_TIMEOUT op=users.list')" - Check
knowledgeandprerequisites: node.js, python, openapi
2. Reason — think for api-error-reproduction
- For
error-reproduction: Reproduce error conditions with curl and scenario payloads — decide which checks to run - For
log-analysis: Correlate errors in logs and metrics to find root causes — decide which checks to run - Evaluate trust/policy:
kdesk trust+kdesk doctorpatterns for your inputs
3. Act — execute with api-error-reproduction tools
- Tools:
Glob,Grep,Read,Bash(see frontmattertools/allowed-tools) - Use
safe_pathfor any write; record evidence (paths, checksums) - Fingerprint:
api-error-reproduction:fcabb7cd
API Error (Troubleshooting)
Diagnoses and fixes error-handling problems in running APIs.
When to Use
- Unexplained 5xx spikes
- Inconsistent error bodies in production
- Errors only appear after deploys
Real Commands
# Reproduce
curl -s -X POST http://localhost:3000/api/users -H 'Content-Type: application/json' -d '{"email":"bad"}' -w '\n%{http_code}'
curl -s http://localhost:3000/api/users/999999 -w '\n%{http_code}'
# Logs
kubectl logs -l app=api --tail=200 | grep -iE 'error|exception' | tail -20
# Metrics
curl -s http://localhost:3000/metrics | grep -E 'http_errors|http_error_total' | head
# Health
curl -s http://localhost:3000/health -w '\n%{http_code}'
Root Cause Checklist
- Is the error body consistent? (format issue)
- When did the spike start? (release correlation)
- Is a dependency failing? (timeouts/upstream)
Testing
Turn each reproduction into an automated regression test.
Best Practices
- Add trace IDs to every error response
- Alert on rate deltas, not raw counts
Capabilities
error-reproduction
Reproduce error conditions with curl and scenario payloads
Parameters:
url(string): Endpoint to probemethod(string): HTTP method
Commands:
curl -s -X POST http://localhost:3000/api/users -H 'Content-Type: application/json' -d '{"email":"bad"}' -w '\n%{http_code}'curl -s http://localhost:3000/api/users/999999 -w '\n%{http_code}'curl -s -X PUT http://localhost:3000/api/users/1 -H 'Content-Type: application/json' -d '{"email":"x@y.z"}' -w '\n%{http_code}'curl -s -X DELETE http://localhost:3000/api/users/1 -w '\n%{http_code}'curl -s -H 'Authorization: Bearer invalid' http://localhost:3000/api/me -w '\n%{http_code}'
Examples:
- curl -s -X POST http://localhost:3000/api/users -H 'Content-Type: application/json' -d '{"email":"bad"}' -w '\n%{http_code}'
- curl -s http://localhost:3000/api/users/999999 -w '\n%{http_code}'
- curl -s -H 'Authorization: Bearer invalid' http://localhost:3000/api/me -w '\n%{http_code}'
log-analysis
Correlate errors in logs and metrics to find root causes
Parameters:
pattern(string): Log filter patternlines(string): Number of log lines
Commands:
node -e "console.log('trace_id=abc123 err=DB_TIMEOUT op=users.list')"curl -s http://localhost:3000/metrics | grep -E 'http_errors|http_error_total' | headkubectl logs -l app=api --tail=200 | grep -iE 'error|exception' | tail -20node -e "const r=require('os');console.log('pid',process.pid,'load',r.loadavg()[0])"curl -s http://localhost:3000/health -w '\n%{http_code}'
Examples:
- kubectl logs -l app=api --tail=200 | grep -iE 'error|exception' | tail -20
- curl -s http://localhost:3000/metrics | grep -E 'http_errors|http_error_total' | head
- curl -s http://localhost:3000/health -w '\n%{http_code}'