refactor(controllers/console): dep-inject workflow payloads with @model_validate - #41244
Open
Terminator666666 wants to merge 2 commits into
Open
Conversation
…el_validate
Migrate the inline Model.model_validate(console_ns.payload or {}) and
request.args parsing in controllers/console/app/workflow.py to the
existing @model_validate decorator. The sync-draft endpoint keeps its
manual parsing because it branches on Content-Type to accept text/plain.
Unit tests that call the handlers directly now pass the validated model.
Ref langgenius#36659
Terminator666666
requested review from
QuantumGhost and
laipz8200
as code owners
August 25, 2026 07:49
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 (claimed in the issue comments).
Migrates
controllers/console/app/workflow.pyto the@model_validatedecorator. This was the largest remaining batch of inline validation calls: 21 handlers doingModel.model_validate(console_ns.payload or {})or parsingrequest.argsby hand now get the validated model injected instead, same pattern as the earlier controllers/web migrations (#40796, #40856).Left as-is on purpose:
model_validate(..., from_attributes=True)calls, which are serialization rather than request parsingOne behavior change: invalid payloads on these endpoints now return 422 from the decorator instead of surfacing a raw pydantic ValidationError.
test_human_input_preview_rejects_non_mappingwas updated to match.From GitHub Copilot
Testing
inspect.unwrap) to pass the explicitly-constructed validated model as the first argument:api/tests/unit_tests/controllers/console/app/test_workflow.pyapi/tests/unit_tests/controllers/console/app/test_workflow_convert_api.pyapi/tests/unit_tests/controllers/console/app/test_workflow_human_input_debug_api.pyuv run --project api --dev pytest tests/unit_tests/controllers→ 3884 passedmake lint→ clean (ruff format/check, response-contract lint, import-linter, dotenv-linter)make type-check→ clean (pyrefly + mypy, 1719 source files, no issues)Screenshots
Checklist
make lint && make type-check(backend) to appease the lint gods. No frontend files changed, sovp staged(frontend) is not applicable.