refactor(api): migrate console.app.workflow to BaseModel#36216
Conversation
Pyrefly Diffbase → PR--- /tmp/pyrefly_base.txt 2026-05-18 07:23:27.101520352 +0000
+++ /tmp/pyrefly_pr.txt 2026-05-18 07:23:16.942496449 +0000
@@ -1824,16 +1824,6 @@
--> tests/unit_tests/controllers/console/app/test_app_response_models.py:112:12
ERROR Object of class `object` has no attribute `exec_module` [missing-attribute]
--> tests/unit_tests/controllers/console/app/test_app_response_models.py:113:5
-ERROR Argument `SimpleNamespace` is not assignable to parameter `workflow` with type `Workflow` in function `controllers.console.app.workflow._parse_file` [bad-argument-type]
- --> tests/unit_tests/controllers/console/app/test_workflow.py:26:40
-ERROR Argument `SimpleNamespace` is not assignable to parameter `workflow` with type `Workflow` in function `controllers.console.app.workflow._parse_file` [bad-argument-type]
- --> tests/unit_tests/controllers/console/app/test_workflow.py:44:42
-ERROR Object of class `FunctionType` has no attribute `assert_called_once_with` [missing-attribute]
- --> tests/unit_tests/controllers/console/app/test_workflow.py:406:5
-ERROR Object of class `FunctionType` has no attribute `call_count` [missing-attribute]
- --> tests/unit_tests/controllers/console/app/test_workflow.py:438:12
-ERROR `in` is not supported between `Literal['Maximum']` and `None` [not-iterable]
- --> tests/unit_tests/controllers/console/app/test_workflow.py:466:12
ERROR Missing argument `app_model` in function `handler` [missing-argument]
--> tests/unit_tests/controllers/console/app/test_wraps.py:21:19
ERROR Unexpected keyword argument `app_id` in function `handler` [unexpected-keyword]
|
Pyrefly Type Coverage
|
|
@dosu how about this pr |
|
This PR is part of the broader Flask-RESTX → Pydantic migration effort tracked in issue #28015 [1], which has already migrated ~64% of targeted files across 23+ PRs. It's well-aligned with that effort. What it does:
Positives:
Minor concerns:
Overall this looks like a solid, well-scoped contribution that advances the migration roadmap toward eventual FastAPI adoption. To reply, just mention @dosu. Share context across your team and agents. Try Dosu. |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
Comments suppressed due to low confidence (2)
api/controllers/console/datasets/rag_pipeline/rag_pipeline_workflow.py:483
- Same as the draft workflow endpoint:
@marshal_withwas removed but this route does not declare a@console_ns.responseschema, so the OpenAPI docs lose the response model. Please add@console_ns.response(200, ..., console_ns.models[WorkflowResponse.__name__])(and the non-200 responses) for the GET handler.
@console_ns.route("/rag/pipelines/<uuid:pipeline_id>/workflows/publish")
class PublishedRagPipelineApi(Resource):
@setup_required
@login_required
@account_initialization_required
@edit_permission_required
@get_rag_pipeline
def get(self, pipeline: Pipeline):
api/controllers/console/datasets/rag_pipeline/rag_pipeline_workflow.py:651
RagPipelineByIdApi.patchremoved@marshal_withand returns aWorkflowResponsedict viadump_response(...), but the route has no@console_ns.responsedeclaration. Add an explicit response schema for 200 (and existing 4xx responses) so the update endpoint remains properly documented in OpenAPI.
@console_ns.route("/rag/pipelines/<uuid:pipeline_id>/workflows/<string:workflow_id>")
class RagPipelineByIdApi(Resource):
@setup_required
@login_required
@account_initialization_required
@edit_permission_required
@get_rag_pipeline
def patch(self, pipeline: Pipeline, workflow_id: str):
Head branch was pushed to by a user without write access
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.
Comments suppressed due to low confidence (3)
api/controllers/console/app/workflow.py:948
- The endpoint documents a 404 ("Published workflow not found"), but the implementation returns
Nonewhen no published workflow exists, which will produce a 200 with a null body. Please align behavior and docs: either raiseNotFoundwhenworkflow is None, or remove the 404 response (and explicitly document that 200 may return null).
console_ns.models[WorkflowResponse.__name__],
)
@console_ns.response(404, "Published workflow not found")
@setup_required
api/controllers/console/datasets/rag_pipeline/rag_pipeline_workflow.py:625
- This wrapper response is manually serialized via
WorkflowPaginationResponse.model_validate(...).model_dump(...). Sincedump_response(...)now handlesfrom_attributes=True+model_dump(mode='json'), consider using it here as well for consistency withcontrollers/API_SCHEMA_GUIDE.md.
return WorkflowPaginationResponse.model_validate(
{
"items": workflows,
"page": page,
"limit": limit,
api/openapi/markdown/console-swagger.md:14229
WorkflowResponse’s schema table is missing severalTypevalues (andenvironment_variablesrenders as[ ]without an item type). Please adjust the schema/markdown generation so array item types and nullable primitives are represented, otherwise the published API docs become ambiguous.
| conversation_variables | [ [WorkflowConversationVariableResponse](#workflowconversationvariableresponse) ] | | No |
| created_at | | | No |
| created_by | | | No |
| environment_variables | [ ] | | No |
| features | object | | No |
84c352e to
d031c3c
Compare
|
@CodingOnStar Please have a look on the touched frontend part. There are two changes:
|
Important
Fixes #<issue number>.Summary
See #28015 . Replace all inline Flask-RESTX request/response payload and query param models to Pydantic BaseModel. Also done minor cleanups for duplicate code.
Affected:
console.app.workflowconsole.app.rag_pipeline_workflowA minor frontend-backend disparency is discovered and fixed. In
web/models/pipeline.ts,RAGPipelineVariablehasallowed_file_extensionsinstead ofallow_file_extension.Other affected frontend parts:
web/service/use-pipeline.ts, use-workflow.ts, workflow.ts: Align the types of APIs which may returnnull, as in the API docs.web/app/components/rag-pipeline/hooks/use-pipeline-config.ts,web/app/components/workflow-app/hooks/use-workflow-init.ts,app/components/rag-pipeline/hooks/__tests__/use-pipeline-config.spec.ts: due to the change of contract, the?? 0has to be brought forward fromsetPublishedAtIntegration tests are changed because the former ones are asserting against the original raw dict return value.
Checklist
make lint && make type-check(backend) andcd web && pnpm exec vp staged(frontend) to appease the lint gods