Skip to content

refactor(api): migrate console workflow-trigger responses to BaseModel#35200

Merged
asukaminato0721 merged 2 commits intolanggenius:mainfrom
ai-hpc:refactor/migrate-console-workflow-trigger-responses-28015
Apr 14, 2026
Merged

refactor(api): migrate console workflow-trigger responses to BaseModel#35200
asukaminato0721 merged 2 commits intolanggenius:mainfrom
ai-hpc:refactor/migrate-console-workflow-trigger-responses-28015

Conversation

@ai-hpc
Copy link
Copy Markdown
Contributor

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

Part of #28015

Summary

Replace get_or_create_model(...) + @marshal_with in console workflow trigger endpoints with registered Pydantic BaseModel response schemas. Migrate webhook trigger, trigger list, and trigger enable responses while keeping response shape unchanged.

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 the size:M This PR changes 30-99 lines, ignoring generated files. label 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

This PR continues the ongoing migration away from Flask-RESTX @marshal_with/api.model(...) patterns by introducing registered Pydantic BaseModel/ResponseModel schemas for the console workflow trigger endpoints, while aiming to keep the response JSON shape unchanged.

Changes:

  • Added Pydantic ResponseModel response schemas for workflow trigger, trigger list, and webhook trigger responses.
  • Replaced @marshal_with(...) usage with @console_ns.response(...) + explicit model_validate(...).model_dump(mode="json") serialization in the affected endpoints.
  • Added unit tests covering Pydantic parsing and datetime JSON serialization behavior for the new response models.

Reviewed changes

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

File Description
api/controllers/console/app/workflow_trigger.py Replaces RESTX marshaling with Pydantic response schemas + explicit JSON dumping for workflow trigger endpoints.
api/tests/unit_tests/controllers/console/app/test_workflow_trigger_api.py Adds unit tests for the new Pydantic parser/response models and datetime JSON serialization.

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

@github-actions
Copy link
Copy Markdown
Contributor

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-04-14 18:30:29.001907737 +0000
+++ /tmp/pyrefly_pr.txt	2026-04-14 18:30:18.467906057 +0000
@@ -693,7 +693,7 @@
 ERROR `dict[str, str | None]` is not assignable to attribute `env` with type `dict[str, str]` [bad-assignment]
    --> tests/test_containers_integration_tests/conftest.py:204:39
 ERROR Argument value `Literal[0]` violates Pydantic `ge` constraint `Literal[1]` for field `page` [bad-argument-type]
-   --> tests/test_containers_integration_tests/controllers/console/app/test_app_apis.py:632:51
+   --> tests/test_containers_integration_tests/controllers/console/app/test_app_apis.py:633:51
 ERROR Argument `Literal['normal']` is not assignable to parameter `status` with type `SQLCoreOperations[TenantStatus] | TenantStatus` in function `models.account.Tenant.__init__` [bad-argument-type]
   --> tests/test_containers_integration_tests/controllers/console/app/test_chat_conversation_status_count_api.py:33:48
 ERROR Object of class `RequestError` has no attribute `response` [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 25c388d 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 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