Skip to content

refactor(api): migrate console message responses from marshal_with to BaseModel#35204

Merged
asukaminato0721 merged 1 commit intolanggenius:mainfrom
ai-hpc:refactor/migrate-console-message-to-pydantic-28015
Apr 14, 2026
Merged

refactor(api): migrate console message responses from marshal_with to BaseModel#35204
asukaminato0721 merged 1 commit intolanggenius:mainfrom
ai-hpc:refactor/migrate-console-message-to-pydantic-28015

Conversation

@ai-hpc
Copy link
Copy Markdown
Contributor

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

Part of #28015

Summary

Extract message response schemas from inline Flask-RESTX api.model(...)/@marshal_with into Pydantic BaseModel classes and register them with register_schema_models(). Keep response compatibility by mapping re_sign_file_url_answer -> answer, message_metadata_dict -> metadata, and normalizing datetime/file-contained fields.

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 message endpoints to stop using inline Flask-RESTX api.model(...) / @marshal_with response definitions and instead serialize responses via Pydantic models registered with register_schema_models(), while preserving key field mappings and normalization.

Changes:

  • Introduces MessageDetailResponse and MessageInfiniteScrollPaginationResponse Pydantic response models (with alias normalization + timestamp conversion).
  • Updates chat-message list and message-detail endpoints to return model_dump(mode="json") output instead of relying on @marshal_with.
  • Adds a unit test covering alias normalization (re_sign_file_url_answeranswer, message_metadata_dictmetadata) and datetime → unix timestamp conversion.

Reviewed changes

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

File Description
api/controllers/console/app/message.py Replaces RESTX marshal models with registered Pydantic response models and uses Pydantic serialization in endpoints.
api/tests/unit_tests/controllers/console/app/test_message_api.py Adds unit coverage for new MessageDetailResponse alias + timestamp normalization behavior.

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

@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 1c3cba2 Apr 14, 2026
32 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