Repository navigation
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
Open
prathamgarg911 wants to merge 1 commit into
prathamgarg911 wants to merge 1 commit into
Conversation
…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>
Contributor
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Automations to automatically generate PRs for you. |
✅ Mintlify HygieneNo issues found. |
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Python example under "Handle errors in code" on the Error Responses page raises
AttributeErrorfor the errors readers hit most. It reads(exc.body or {}).get("error", {}).get("code"), which assumesexc.bodyis a dict. Withhydradb-sdk2.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="")raisesBadRequestErrorwith aHandlerErrorResponsebody, and the documented handler then fails withAttributeError: 'HandlerErrorResponse' object has no attribute 'get'. A401and a404 DATABASE_NOT_FOUNDcarry 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_envelopehelper that returns a dict whether the SDK handed over a dict, a typed model or a string, and it also readsmeta.request_id. The sentence on the SDKs page that told readers to readbody["error"]["code"]points at the helper instead.scripts/test_docs_examples.pygainsErrorHandlingExample, which runs theexcept ApiErrorblock 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 noexceptbranch ran in CI before.Two pages said to send
API-Version: 2with every request, and the 401 troubleshooting entry suggested the header as a fix. The API answers as version 2 whatever the header says:GET /databaseson staging returned the same200withmeta.api_version: 2.0.1with no header, with2, with1and withbanana. 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 FORBIDDENfrom 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_versionand410 ENDPOINT_RETIREDto 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 ofsdks.mdx, including the one sentence changed here, and both change the arguments of theclient.context.ingestcall 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 (
querywith an empty query, typed body): old raisesAttributeError, new readsINVALID_INPUT. 401 (bad key, dict body) and 404 (missing database onqueryandcontext.status, dict body): both read the code, new also reads the request id. The whole example as printed, run against staging wheremy_first_databasedoes not exist, takes theDATABASE_NOT_FOUNDbranch. 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'sdatabases.create(ForbiddenError, typed body): old raisesAttributeError, new readsFORBIDDEN. Locally:scripts/test_docs_consistency.pyOK;python -m unittest discover -s scripts -p 'test_*.py'runs 44 tests with the same 12 failures asmain(theapp_knowledgeandacl_inheritbaseline) and the new test passing, and the new test fails against the page as it is onmain;.github/verify_v2_public_contract.py,scripts/verify_agents_endpoints.py,scripts/generate_llms_index.py --checkandpnpm mintlify validatepass.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