Skip to content

refactor(console): dep-inject account payloads with @model_validate - #41500

Merged
asukaminato0721 merged 2 commits into
langgenius:mainfrom
ShousenZHANG:refactor/dep-inject-console-account
Aug 31, 2026
Merged

refactor(console): dep-inject account payloads with @model_validate#41500
asukaminato0721 merged 2 commits into
langgenius:mainfrom
ShousenZHANG:refactor/dep-inject-console-account

Conversation

@ShousenZHANG

@ShousenZHANG ShousenZHANG commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Summary

part of #36659

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. Claimed in this comment.

Fourteen POST bodies plus the one GET query — EducationAutoCompleteApi.get reads request.args.to_dict(flat=True), which is exactly the decorator's GET branch.

Deliberately left alone

The rest of console/workspace. skills.py returns a locally-asserted {"code": ..., "message": ...}, 400 on validation errors, and #41280 is rewriting its handler signatures. members.py, workspace.py and rbac.py all 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_api conversions, a malformed body now returns 422 with the pydantic error JSON instead of 400 — test_accounts.py already 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.py47 passed, identical count to main
  • ruff check / ruff format --check — clean; pyrefly check — 0 diagnostics
  • Enumerated every test call site of the 15 handlers by identity: 24 unwrapped-view calls updated across both test files (the deprecated-update-routes parametrization gains the payload model per row); the pre-converted avatar/profile tests already conform and are untouched
  • Added one bound-method test so the decorators are actually exercised: the existing tests all go through inspect.unwrap and 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.

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.
Copilot AI lite review requested due to automatic review settings August 30, 2026 23:03
@dosubot dosubot Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Aug 30, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

github-actions Bot commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Pyrefly Type Coverage

Metric Base PR Delta
Type coverage 61.53% 61.54% +0.01%
Strict coverage 61.13% 61.14% +0.01%
Typed symbols 42,641 42,657 +16
Untyped symbols 26,836 26,838 +2
Modules 3278 3278 0

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
asukaminato0721 added this pull request to the merge queue Aug 31, 2026
Merged via the queue into langgenius:main with commit 6130f08 Aug 31, 2026
38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants