Skip to content

refactor(api): migrate console conversation variables response model to BaseModel#35193

Merged
asukaminato0721 merged 2 commits intolanggenius:mainfrom
ai-hpc:refactor/migrate-conversation-variables-to-pydantic-28015
Apr 14, 2026
Merged

refactor(api): migrate console conversation variables response model to BaseModel#35193
asukaminato0721 merged 2 commits intolanggenius:mainfrom
ai-hpc:refactor/migrate-conversation-variables-to-pydantic-28015

Conversation

@ai-hpc
Copy link
Copy Markdown
Contributor

@ai-hpc ai-hpc commented Apr 14, 2026

Part of #28015

Summary

Extract Flask-RESTX response model usage in api/controllers/console/app/conversation_variables.py into Pydantic ResponseModel classes and register them with register_schema_models(). Remove @marshal_with and inline console_ns.model(...) response model assembly for conversation variable pagination responses.

Checklist

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran make lint and make type-check (backend) and cd web && pnpm exec vp staged (frontend) to appease the lint gods

@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. refactor labels Apr 14, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Pyrefly Diff

No changes detected.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Refactors the console conversation variables GET endpoint to replace Flask-RESTX response marshalling/models with Pydantic ResponseModel classes registered via register_schema_models().

Changes:

  • Introduces ConversationVariableResponse and PaginatedConversationVariableResponse Pydantic models and registers them for Swagger.
  • Removes @marshal_with and inline console_ns.model(...) assembly, returning model_dump(mode="json") instead.
  • Adds unit tests for the conversation variables API response shape and query validation.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
api/controllers/console/app/conversation_variables.py Migrates response modeling/marshalling to Pydantic ResponseModel + schema registration and returns JSON via model_dump.
api/tests/unit_tests/controllers/console/app/test_conversation_variables_api.py Adds unit tests covering paginated response structure and missing conversation_id validation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

auto-merge was automatically disabled April 14, 2026 18:15

Head branch was pushed to by a user without write access

@github-actions
Copy link
Copy Markdown
Contributor

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-04-14 18:16:41.177957338 +0000
+++ /tmp/pyrefly_pr.txt	2026-04-14 18:16:30.954838437 +0000
@@ -1,5 +1,7 @@
 ERROR Object of class `App` has no attribute `access_mode` [missing-attribute]
    --> controllers/console/app/app.py:561:13
+ERROR Object of class `object` has no attribute `value` [missing-attribute]
+  --> controllers/console/app/conversation_variables.py:48:24
 ERROR Argument `str | None` is not assignable to parameter `language` with type `str` in function `services.account_service.AccountService.send_email_register_email` [bad-argument-type]
   --> controllers/console/auth/email_register.py:75:108
 ERROR Object of class `MissingRouter` has no attribute `get` [missing-attribute]

@asukaminato0721 asukaminato0721 added this pull request to the merge queue Apr 14, 2026
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Apr 14, 2026
Merged via the queue into langgenius:main with commit b1722c8 Apr 14, 2026
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer refactor size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants