Repository navigation
feat(client-contract): add client codes for unsafe keys, headers, base URLs, transport and oversized bodies - #16
Merged
Conversation
…e URLs, transport and oversized bodies key_invalid, credentials_file_unreadable, header_invalid, insecure_transport, base_url_invalid and response_too_large let the clients refuse an unsafe key, header value or base URL, a key over plain http to a remote host, an unreadable credentials file and a decoded body past its cap, each under its own code. None is retryable.
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 SDK clients are about to refuse several inputs and responses they accept today: a key holding characters outside visible ASCII, a header value holding a control character, a base URL that is empty, not absolute http(s) or carries userinfo, a key that would travel over plain http to a host that is not loopback, a credentials file that exists but cannot be read, and a decoded response body past its size cap.
client-codes.jsongains a row for each, so both clients raise them under a precise code:key_invalidandcredentials_file_unreadable(AuthenticationError),header_invalid,insecure_transportandbase_url_invalid(InvalidRequestError), andresponse_too_large(ServerError). None is retryable. The README's client-codes paragraph names them, and the CHANGELOG counts 23 codes.Testing:
uv run tools/validate_client_contract.pyreports 23 client codes and a valid contract,tools/testsgives 517 passed, andpython/client-contractgives 78 passed with ruff and ty clean.