Repository navigation
fix: expose the API errorCode as KeyMintApiError.error_code - #6
Merged
Merged
Conversation
KeyMintApiError now carries the response body's errorCode catalogue string (e.g. activation_limit_reached, license_not_found, rate_limited) as error_code, or None when the body has none. The constructor and existing attributes are unchanged; error_code is a new optional fourth argument. A JSON body that isn't an object no longer escapes as AttributeError. README: add an Error Handling section that branches on error_code, and correct the Idempotency section: the floating endpoints ignore Idempotency-Key, so replays never return floating-session secrets.
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.
Summary
KeyMintApiErrorgainserror_code: the response body'serrorCodecatalogue string (activation_limit_reached,license_not_found,rate_limited, ...), orNonewhen absent (noerrorCode, non-JSON body, network error).message,code,statusand the positional constructor(message, code, status=None)are unchanged;error_codeis an optional fourth argument.str(err)is still the message.AttributeError.Idempotency-Keyon checkout/heartbeat/checkin.error_code; Idempotency section corrected (replays never return floating-session secrets, because the floating endpoints ignoreIdempotency-Key).example.pyprintserror_code.No version bump.
Tests
pytest -q tests: 90 passed (new: witherrorCode, legacy envelope pluserrorCode, withouterrorCode, non-JSON body, non-object JSON body, constructor compatibility).ruff check .clean.