Repository navigation
feat!: pass a catalog value newer than the client through - #25
Merged
Merged
Conversation
Every catalog field of a returned model is typed `Literal[...] | str`. A value the API adds later now arrives as it is, where the whole call raised a `ValidationError` before. Method arguments keep their closed types, and so does the `type` of a release condition. One contract test answers every call with catalog values the client does not know, so a response field typed as a closed `Literal` fails it. BREAKING CHANGE: a catalog field of a returned model is typed `Literal[...] | str`. Code checked with mypy or pyright needs a branch for an unknown value, and must narrow a response value before it passes it to a method argument. See BREAKING.md. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ondition A release that carries a condition of a type newer than the client can be read again. The condition arrives as an `UnknownCondition`. It keeps its `type`, and its other fields are in `model_extra`. Before, the whole call raised a `ValidationError`. The `conditions` argument of `apps.channels.releases.create` takes only the five known models. The contract test now answers every condition with an unknown type too. BREAKING CHANGE: `Release.conditions` is a list of `ReleaseCondition | UnknownCondition`. Code checked with mypy or pyright needs a branch for `UnknownCondition`, and a check of `condition.type` no longer narrows the model. See BREAKING.md. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
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
The client no longer fails a call because the API answers a catalog value it does not know. A value newer than the client passes through, as an unknown error code already does.
What changes
Catalog fields of returned models. Every one of the 32 catalog fields is typed
Literal[...] | str, such asApp.frameworkasFramework | str. Before, an unknown value raised a pydanticValidationErrorfor the whole call. Method arguments keep their closed types.Release conditions.
Release.conditionsis a list ofReleaseCondition | UnknownCondition. A condition the client cannot read, such as one of a type newer than the client, arrives as the newUnknownCondition. It keeps itstype, and its other fields are inmodel_extra. Theconditionsargument ofapps.channels.releases.createtakes only the five known models.The known condition models are tried first. So a condition of a known type that lacks a required field is also read as an
UnknownCondition, where it failed the call before. A condition without atypestill fails the call.Breaking for typed code
Nothing changes at runtime for the values the client knows. Code checked with mypy or pyright must change in these cases, and
BREAKING.mdshows each one:UnknownConditioncondition.typeno longer narrows the modelTests
One contract test answers every call with catalog values and condition types the client does not know. It fails when a response field is typed as a closed
Literalagain, and whenUnknownConditionleaves the union. The existing contract test fails when the order of the union is turned around.Verification
🤖 Generated with Claude Code