Skip to content

docs: error handling example works for every error body; version header and plan database limit stated accurately - #390

Open
prathamgarg911 wants to merge 1 commit into
mainfrom
pratham/docs-error-snippet
Open

prathamgarg911 wants to merge 1 commit into
mainfrom
pratham/docs-error-snippet

Conversation

@prathamgarg911

@prathamgarg911 prathamgarg911 commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

The Python example under "Handle errors in code" on the Error Responses page raises AttributeError for the errors readers hit most. It reads (exc.body or {}).get("error", {}).get("code"), which assumes exc.body is a dict. With hydradb-sdk 2.1.7 the body is a typed model for the statuses the spec declares on an operation and a dict for the rest. Reproduced against staging: client.query(database=<existing>, query="") raises BadRequestError with a HandlerErrorResponse body, and the documented handler then fails with AttributeError: 'HandlerErrorResponse' object has no attribute 'get'. A 401 and a 404 DATABASE_NOT_FOUND carry a dict and work. A response that is not JSON arrives as a string and fails the same way.

The example now reads the envelope through a small error_envelope helper that returns a dict whether the SDK handed over a dict, a typed model or a string, and it also reads meta.request_id. The sentence on the SDKs page that told readers to read body["error"]["code"] points at the helper instead. scripts/test_docs_examples.py gains ErrorHandlingExample, which runs the except ApiError block from the page through the real SDK against a 400, 401, 403, 404 and a plain-text 404 and requires that the cases cover all three body shapes. The existing example tests only ever return successful responses, so no except branch ran in CI before.

Two pages said to send API-Version: 2 with every request, and the 401 troubleshooting entry suggested the header as a fix. The API answers as version 2 whatever the header says: GET /databases on staging returned the same 200 with meta.api_version: 2.0.1 with no header, with 2, with 1 and with banana. The API Reference conventions and the 401 entry say the header is optional. The cURL examples still send it, as the SDKs do.

The quickstart tells the reader to create a database without saying that the count depends on the plan. On Ship, which holds one database, a workspace that already has one gets 403 FORBIDDEN from that step. The paragraph above the example states the count per plan (Ship one database with unlimited collections, Scale and Enterprise no limit, taken from the plan definitions in the API source), says how to list the databases the workspace has, and says to use the existing one, where the example's own collections keep its data apart.

Overlap with open PRs. #333 already adds detail, meta.api_version and 410 ENDPOINT_RETIRED to the envelope, status and error-code tables of the Error Responses page, so this PR does not touch those tables and leaves those three additions to #333 (it is approved and currently has conflicts with main). None of the lines changed here are changed by #333. #299 and #301 are page-wide rewrites from September: #299 rewrites nearly all of sdks.mdx, including the one sentence changed here, and both change the arguments of the client.context.ingest call inside the same Python example, next to the lines changed here. That could not be avoided while fixing the example; whichever lands second needs a small rebase there.

Verified by running: the old and new handler text taken from the page, against real SDK exceptions from staging. 400 (query with an empty query, typed body): old raises AttributeError, new reads INVALID_INPUT. 401 (bad key, dict body) and 404 (missing database on query and context.status, dict body): both read the code, new also reads the request id. The whole example as printed, run against staging where my_first_database does not exist, takes the DATABASE_NOT_FOUND branch. The 403 was not called live: the only 403 this key can reach is a database create, which is a write if the limit is ever raised. Instead a 403 body staging returned for that call earlier today was replayed through the real SDK's databases.create (ForbiddenError, typed body): old raises AttributeError, new reads FORBIDDEN. Locally: scripts/test_docs_consistency.py OK; python -m unittest discover -s scripts -p 'test_*.py' runs 44 tests with the same 12 failures as main (the app_knowledge and acl_inherit baseline) and the new test passing, and the new test fails against the page as it is on main; .github/verify_v2_public_contract.py, scripts/verify_agents_endpoints.py, scripts/generate_llms_index.py --check and pnpm mintlify validate pass.

Not changed: the cURL loop in the quickstart that polls status forever when the create call fails, the plan limit on the Create Database and Databases and Collections pages, and whether the quickstart should start from the database a workspace already has.

🤖 Generated with Claude Code

…der and plan limit made accurate

The Python example on the Error Responses page read exc.body with .get().
The SDK parses the body into a typed model for some statuses (400 and 403
on most operations), so the example raised AttributeError there, and a
body that is not JSON arrives as a string. The example reads the envelope
through a helper that accepts all three, and a test runs it against each.

The API answers as version 2 with or without the API-Version header, so
the pages no longer say it must be sent. The quickstart states how many
databases each plan holds and what to do when the workspace already has
one.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Signed-off-by: prathamgarg911 <prathamgarg45@gmail.com>
@mintlify

mintlify Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated
cortex-ai 🟢 Ready View Preview Nov 24, 2026, 6:46 AM

💡 Tip: Enable Automations to automatically generate PRs for you.

@github-actions

Copy link
Copy Markdown

✅ Mintlify Hygiene

No issues found.

This branch was successfully deployed

1 active deployment
staging — 8f29c3c0 Deployed Nov 24, 2026 by mintlify[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant