Stop sending dfiq_type in DFIQ create and patch payloads - #27
Merged
Merged
Conversation
yeti#1340 removed dfiq_type from NewDFIQRequest, PatchDFIQRequest and DFIQValidateRequest -- the API reads the type from the YAML or the object. Those models set extra="forbid", so every call to new_dfiq_from_yaml, patch_dfiq_from_yaml and patch_dfiq now gets a 422. The dfiq_type parameters stay in the two from_yaml signatures and raise a DeprecationWarning instead of being removed: dfiq_type is the first positional argument of both, so dropping it would silently rebind existing positional callers' arguments. patch_dfiq took the value from dfiq_object["type"], so it needs no signature change. Version bumped to 2.3.1 so the release can be cut without a second commit on main. Fixes #26.
Nothing in tests/e2e.py called new_dfiq_from_yaml, patch_dfiq_from_yaml or patch_dfiq, so the 422 in #26 reached a release with a green e2e run. The new test walks a scenario through all three against the live API, which is the only place the request models' extra="forbid" is enforced -- the unit tests assert the payload we build, not what the API accepts.
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.
Fixes #26.
yeti#1340 dropped
dfiq_typefromNewDFIQRequest,PatchDFIQRequestandDFIQValidateRequest, because the API now reads the type from the YAML or the object payload. All three models setmodel_config = ConfigDict(extra="forbid"), so anything this client sends in that field comes back as422 Unprocessable Entity — Extra inputs are not permitted.What changed
Three payloads stop carrying the field:
new_dfiq_from_yaml→POST /api/v2/dfiq/from_yamlpatch_dfiq_from_yaml→PATCH /api/v2/dfiq/{yeti_id}patch_dfiq→PATCH /api/v2/dfiq/{id}Why the parameters stay
The issue offered a choice between deprecating
dfiq_typeand removing it. This keeps it, for one reason: it is the first positional parameter of bothfrom_yamlmethods. Removing it would rebind existing positional callers' arguments —new_dfiq_from_yaml("scenario", yaml)would pass"scenario"as the YAML — and no repo in the organisation calls these methods, so every consumer is external and invisible from here. The parameter is accepted, ignored, documented as ignored, and raises aDeprecationWarning. A clean removal belongs in the next major version, which the warning text says.patch_dfiqneeded no signature change; it was deriving the value fromdfiq_object["type"]itself.The other
dfiq_typeparameters in the client —find_dfiq,search_dfiq,download_dfiq_archive— are query filters, not request-body fields, and are untouched.e2e coverage
Nothing in
tests/e2e.pyexercised any of the three methods, which is why this reached a release with a green e2e run.test_dfiq_from_yaml_and_patchnow walks one scenario through all three against the live API. That matters because the unit tests only assert the payload the client builds —extra="forbid"is enforced by the server and nowhere else.Verification
Unit and type checks, run the way CI does via
poetry install --no-root:poetry run python -m unittest tests/api.py— 37 passedpoetry run pyrefly check— 0 errorspoetry run python -m unittest tests.e2e.YetiEndToEndTest.test_dfiq_from_yaml_and_patchagainst a live dev stack — passedAlso driven by hand against that stack, with the patched client, to confirm the fix rather than infer it:
The last two lines are the same request with
dfiq_typerestored, i.e. what the current release sends — so the 422 in #26 is reproduced, and the new e2e test would catch the field coming back. Both test objects were deleted afterwards.Release
Version is bumped to 2.3.1 in this PR, so no second commit on
mainis needed. Once this merges, the release still needs the bare tag (2.3.1) and a published GitHub release — publishing is what triggers the PyPI push.