refactor(console): dep-inject account payloads with @model_validate - #41500
Merged
asukaminato0721 merged 2 commits intoAug 31, 2026
Merged
Conversation
Moves the 15 remaining inline parses in console/workspace/account.py onto the @model_validate decorator the file already imports, completing what AccountProfileApi.patch and AccountAvatarApi.get started there. Fourteen POST bodies plus the one GET query (EducationAutoCompleteApi reads request.args, which is exactly the decorator's GET branch). Tests that invoke the unwrapped view now build the model from the request body and pass it where the decorator would have injected it, the same shape the existing AccountProfileApi and AccountAvatarApi tests already use. The deprecated-update-routes parametrization gains the payload model per row.
Contributor
Pyrefly Type Coverage
|
The two edited test files reach the handlers through inspect.unwrap and build the model by hand, so nothing exercised the decorators this PR adds — removing all fifteen of them left the console suite green. Adds one bound-method test that asserts the 422 the decorator raises, mirroring the existing test_get_avatar_missing_query_returns_unprocessable_entity. Also removes the blank lines the parse statements left behind in seven handler bodies.
asukaminato0721
enabled auto-merge
August 31, 2026 00:29
asukaminato0721
approved these changes
Aug 31, 2026
This was referenced Aug 31, 2026
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
part of #36659
Moves the 15 remaining inline parses in
console/workspace/account.pyonto the@model_validatedecorator the file already imports, completing whatAccountProfileApi.patchandAccountAvatarApi.getstarted there. Claimed in this comment.Fourteen POST bodies plus the one GET query —
EducationAutoCompleteApi.getreadsrequest.args.to_dict(flat=True), which is exactly the decorator's GET branch.Deliberately left alone
The rest of
console/workspace.skills.pyreturns a locally-asserted{"code": ..., "message": ...}, 400on validation errors, and #41280 is rewriting its handler signatures.members.py,workspace.pyandrbac.pyall have active PRs on them.model_providers.py(8 sites) is the same mechanical shape and would be a fine follow-up — I left it out only to keep this reviewable alongside the tests it needs.Behaviour notes
As with the
service_apiconversions, a malformed body now returns 422 with the pydantic error JSON instead of 400 —test_accounts.pyalready asserts that contract for the converted profile handlers.How did you test it?
pytest tests/unit_tests/controllers/console/workspace/test_accounts.py tests/unit_tests/controllers/console/test_workspace_account.py— 47 passed, identical count tomainruff check/ruff format --check— clean;pyrefly check— 0 diagnosticsinspect.unwrapand build the model themselves, so removing every decorator this PR adds left the suite green. Deleting one now fails that test.This PR was fully generated with an AI assistant. I have reviewed the changes and run the relevant tests.