{"record":{"id":"4013d5aa63ad3972","repo":"affaan-m/ECC","slug":"x-api-error-resp-status-code-resp-text","errorCode":null,"errorMessage":"X API error {resp.status_code}: {resp.text}","messagePattern":"X API error (.+?): (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"skills/x-api/SKILL.md","lineNumber":208,"sourceCode":"if remaining < 5:\n    reset = int(resp.headers.get(\"x-rate-limit-reset\", 0))\n    wait = max(0, reset - int(time.time()))\n    print(f\"Rate limit approaching. Resets in {wait}s\")\n```\n\n## Error Handling\n\n```python\nresp = oauth.post(\"https://api.x.com/2/tweets\", json={\"text\": content})\nif resp.status_code == 201:\n    return resp.json()[\"data\"][\"id\"]\nelif resp.status_code == 429:\n    reset = int(resp.headers[\"x-rate-limit-reset\"])\n    raise Exception(f\"Rate limited. Resets at {reset}\")\nelif resp.status_code == 403:\n    raise Exception(f\"Forbidden: {resp.json().get('detail', 'check permissions')}\")\nelse:\n    raise Exception(f\"X API error {resp.status_code}: {resp.text}\")\n```\n\n## Security\n\n- **Never hardcode tokens.** Use environment variables or `.env` files.\n- **Never commit `.env` files.** Add to `.gitignore`.\n- **Rotate tokens** if exposed. Regenerate at developer.x.com.\n- **Use read-only tokens** when write access is not needed.\n- **Store OAuth secrets securely** — not in source code or logs.\n\n## Integration with Content Engine\n\nUse `brand-voice` plus `content-engine` to generate platform-native content, then post via X API:\n1. Pull recent original posts when voice matching matters\n2. Build or reuse a `VOICE PROFILE`\n3. Generate content with `content-engine` in X-native format\n4. Validate length and thread structure\n5. Return the draft for approval unless the user explicitly asked to post now","sourceCodeStart":190,"sourceCodeEnd":226,"githubUrl":"https://github.com/affaan-m/ECC/blob/06c5e118c4d3e6c3b7f9445f973a2194c82de193/skills/x-api/SKILL.md#L190-L226","documentation":"Documented example in the x-api skill's Error Handling section: after an X API POST, any non-201/non-429/non-403 status raises this error embedding the status code and raw response body for debugging.","triggerScenarios":"Triggered when SKILL.md rejects the current invocation: X API error <value>: <value>","commonSituations":"Occurs while running skills/x-api/SKILL.md with invalid arguments, missing flags, or a failing external dependency; the guard at skills/x-api/SKILL.md:208 aborts the command with this message.","solutions":["Inspect the underlying error detail in the message (stderr/log/HTTP status), fix the cause, and retry."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"06c5e118c4d3e6c3b7f9445f973a2194c82de193","analyzedAt":"2026-08-18T11:27:13.915Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}