词元广场TOKPUB.COM - 欢迎您,支持一个 Key 调用近 600+ 海内外模型,限时特价模型低至 1 折,欢迎上岸!
| 来源 | 可选 — 通过 hermes skills install official/software-development/rest-graphql-debug 安装 |
| 路径 | optional-skills/software-development/rest-graphql-debug |
| 版本 | 1.2.0 |
| 作者 | eren-karakus0 |
| 许可证 | MIT |
| 标签 | api, rest, graphql, http, debugging, testing, curl, integration |
| 相关 skill | systematic-debugging、test-driven-development |
terminal 用于 curl,execute_code 用于 Python requests,web_extract 用于查阅厂商文档。在猜测修复方案之前,先隔离出故障层。1. 连通性 → 能否访问到主机?
1.5 超时 → 连接慢还是读取慢?
2. TLS/SSL → 证书是否有效且受信任?
3. 认证 → 凭据是否正确且未过期?
4. 请求格式 → payload 结构是否符合服务端预期?
5. 响应解析 → 代码是否能接受返回的内容?
6. 语义 → 数据含义是否符合我们的假设?errors 字段:requests 没有默认值,会永久挂起:time_connect 高说明是网络/防火墙问题;time_connect 低但 time_starttransfer 高说明是服务端响应慢。-k 仅用于临时调试,不得写入代码。exp 声明)X-Api-Key?api_key=…)中?.json() 前始终检查 content-type:"status": "active" 的含义是否符合代码预期?Authorization 请求头是否实际存在?(用 curl -v 确认)Bearer vs Basic vs Token)?api_key=…)而非请求头。Access-Control-Allow-Origin)/v1/ vs /v2/)?ETag / If-Match 是否过期?Retry-After 和 X-RateLimit-* 响应头。指数退避:next_cursor、next_page、total_count。两种常见模式:?limit=100&offset=200)—— 简单,但数据变动时可能跳过条目。?cursor=abc123)—— 适用于实时或大数据集,推荐使用。Idempotency-Key: <uuid>,确保重试不会重复扣款或重复创建。支付和订单场景必须使用。Endpoint: POST /api/v1/orders
Request ID: req_abc123xyz
Timestamp: 2026-03-17T14:30:00Z
Status: 500
Expected: 201 with order object
Actual: 500 {"error":"internal server error"}
Repro: curl -X POST … (auth: <REDACTED>)tests/ 目录,通过 terminal('pytest tests/test_api_smoke.py -v') 运行:Bearer <REDACTED>。os.environ["API_TOKEN"])或 ~/.hermes/.env 读取。404 on /users/123 不应暴露该用户是否存在(枚举攻击)。10.x.x.x、internal-api.corp.local。Server / X-Powered-By。 技术栈信息泄露。记录以供安全审查。execute_code。变量在脚本内持久存在,结果打印到 stdout,不会在上下文中产生 token 污染:## Finding
Endpoint: POST /api/v1/users
Status: 422 Unprocessable Entity
Req ID: req_abc123xyz
## Repro
curl -X POST https://api.example.com/api/v1/users \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer <REDACTED>' \
-d '{"name":"test"}'
## Root Cause
Missing required field `email`. Server validation rejects before processing.
## Fix
-d '{"name":"test","email":"test@example.com"}'systematic-debugging —— 隔离出故障 API 层后,对代码进行根因分析test-driven-development —— 在发布修复前先编写回归测试