refactor(inner_api): dep-inject workspace payloads with @model_validate - #41540
Open
ShousenZHANG wants to merge 3 commits into
Open
refactor(inner_api): dep-inject workspace payloads with @model_validate#41540ShousenZHANG wants to merge 3 commits into
ShousenZHANG wants to merge 3 commits into
Conversation
Moves the three inline parses in inner_api/workspace/workspace.py onto the @model_validate decorator: EnterpriseWorkspace.post, EnterpriseWorkspaceNoOwnerEmail.post and EnterpriseWorkspaceMember.post. The handler tests patched inner_api_ns to feed the payload; they now put it in the request context and pass the validated model where the decorator injects it. Also adds one bound-method test for the decorator, since every other test in the file unwraps the view and builds the model itself — without it the decorators here would ship unexercised.
Contributor
Pyrefly Type Coverage
|
…orators The decorator test passed json= without a method, and test_request_context defaults to GET, so the decorator took its request.args branch and the JSON body these three POST handlers actually use was never read — the test passed with a valid body too. It now sends method="POST" and is parametrized over all three handlers; each is individually detected when its decorator is removed. Also drops the blank lines the parse statements left behind.
CI's Python Style job runs pyrefly over tests/ with its own config; the new parametrized test needed a return annotation and a type for api_cls.
Contributor
Pyrefly Diffbase → PR--- /tmp/pyrefly_base.txt 2026-08-31 15:59:08.369260738 +0000
+++ /tmp/pyrefly_pr.txt 2026-08-31 15:59:00.597216108 +0000
@@ -3614,6 +3614,8 @@
--> tests/unit_tests/controllers/inner_api/plugin/test_plugin_wraps.py:388:35
ERROR Missing argument `payload` in function `protected_view` [missing-argument]
--> tests/unit_tests/controllers/inner_api/plugin/test_plugin_wraps.py:394:36
+ERROR Object of class `Resource` has no attribute `post` [missing-attribute]
+ --> tests/unit_tests/controllers/inner_api/workspace/test_workspace.py:364:17
ERROR Object of class `FromClause` has no attribute `create` [missing-attribute]
--> tests/unit_tests/controllers/mcp/test_mcp.py:38:13
ERROR `SimpleNamespace` is not assignable to attribute `mcp_ns` with type `Namespace` [bad-assignment]
|
asukaminato0721
enabled auto-merge
September 1, 2026 04:24
asukaminato0721
approved these changes
Sep 1, 2026
github-merge-queue
Bot
removed this pull request from the merge queue due to no response for status checks
Sep 1, 2026
Contributor
Author
|
@asukaminato0721 this one has been approved and green since Aug 31 — I think it just got skipped when #41571 and #41575 went through this morning. Still |
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Sep 2, 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 three inline parses in
inner_api/workspace/workspace.pyonto the@model_validatedecorator —EnterpriseWorkspace.post,EnterpriseWorkspaceNoOwnerEmail.postandEnterpriseWorkspaceMember.post. Same change as #41374, #41490, #41491, #41500, #41501 and #41539.Nothing else in
inner_apithis round:agent/{llm,tools,files}.pyandknowledge/retrieval.pyraise custom*HttpError(400)from a localexcept ValidationError, andapp/dsl.py:110returns its own{"code": "invalid_workflow_id"}, 400— converting those would change documented error contracts rather than just move the parse.How did you test it?
pytest tests/unit_tests/controllers/inner_api/— 155 passed, against 152 onmain; the three extra are the parametrized decorator test added hereruff check/ruff format --check— clean;pyrefly check— 0 diagnosticsinner_api_nsto supply the payload; they now put it in the request context and pass the validated model where the decorator injects it. Eight call sites, all intest_workspace.py, verified by handler identityThis PR was fully generated with an AI assistant. I have reviewed the changes and run the relevant tests.