refactor(api): migrate service conversation-variable responses to BaseModel#35205
Merged
asukaminato0721 merged 2 commits intolanggenius:mainfrom Apr 14, 2026
Conversation
Contributor
Pyrefly Diffbase → PR--- /tmp/pyrefly_base.txt 2026-04-14 17:51:40.961865292 +0000
+++ /tmp/pyrefly_pr.txt 2026-04-14 17:51:30.345884904 +0000
@@ -14,6 +14,8 @@
--> controllers/console/setup.py:65:2
ERROR Object of class `MissingRouter` has no attribute `get` [missing-attribute]
--> controllers/console/version.py:30:2
+ERROR Object of class `object` has no attribute `value` [missing-attribute]
+ --> controllers/service_api/app/conversation.py:86:24
ERROR Class member `EasyUIBasedGenerateTaskPipeline._application_generate_entity` overrides parent class `BasedGenerateTaskPipeline` in an inconsistent manner [bad-override]
--> core/app/task_pipeline/easy_ui_based_generate_task_pipeline.py:75:5
ERROR `+=` is not supported between `list[PromptMessageContentUnionTypes]` and `str` [unsupported-operation]
@@ -2115,11 +2117,11 @@
ERROR Argument `list[dict[str, Any]] | None` is not assignable to parameter `obj` with type `Sized` in function `len` [bad-argument-type]
--> tests/unit_tests/controllers/service_api/app/test_completion.py:156:20
ERROR Argument value `Literal[0]` violates Pydantic `ge` constraint `Literal[1]` for field `limit` [bad-argument-type]
- --> tests/unit_tests/controllers/service_api/app/test_conversation.py:80:35
+ --> tests/unit_tests/controllers/service_api/app/test_conversation.py:84:35
ERROR Argument value `Literal[101]` violates Pydantic `le` constraint `Literal[100]` for field `limit` [bad-argument-type]
- --> tests/unit_tests/controllers/service_api/app/test_conversation.py:85:35
+ --> tests/unit_tests/controllers/service_api/app/test_conversation.py:89:35
ERROR Missing argument `session` in function `services.conversation_service.ConversationService.pagination_by_last_id` [missing-argument]
- --> tests/unit_tests/controllers/service_api/app/test_conversation.py:383:59
+ --> tests/unit_tests/controllers/service_api/app/test_conversation.py:426:59
ERROR Argument value `Literal[0]` violates Pydantic `ge` constraint `Literal[1]` for field `limit` [bad-argument-type]
--> tests/unit_tests/controllers/service_api/app/test_message.py:94:63
ERROR Argument value `Literal[101]` violates Pydantic `le` constraint `Literal[100]` for field `limit` [bad-argument-type]
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR migrates Service API conversation-variable response serialization from Flask-RESTX @marshal_with(...) models to Pydantic ResponseModel classes in api/controllers/service_api/app/conversation.py, aiming to keep the response shape consistent while normalizing value_type and timestamps.
Changes:
- Introduces Pydantic response models for conversation-variable item and infinite-scroll pagination responses.
- Updates the conversation-variable list/update endpoints to return
model_dump(mode="json")output instead of RESTX marshalling. - Adds unit tests covering
value_typeand timestamp normalization plus basic controller serialization checks.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| api/controllers/service_api/app/conversation.py | Adds Pydantic response models + swaps endpoint serialization from RESTX marshalling to model_validate(...).model_dump(...). |
| api/tests/unit_tests/controllers/service_api/app/test_conversation.py | Adds unit tests for the new response models and controller response serialization. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
auto-merge was automatically disabled
April 14, 2026 18:17
Head branch was pushed to by a user without write access
Contributor
Pyrefly Diffbase → PR--- /tmp/pyrefly_base.txt 2026-04-14 18:19:04.933855331 +0000
+++ /tmp/pyrefly_pr.txt 2026-04-14 18:18:54.020721458 +0000
@@ -14,6 +14,8 @@
--> controllers/console/setup.py:65:2
ERROR Object of class `MissingRouter` has no attribute `get` [missing-attribute]
--> controllers/console/version.py:30:2
+ERROR Object of class `object` has no attribute `value` [missing-attribute]
+ --> controllers/service_api/app/conversation.py:87:24
ERROR Class member `EasyUIBasedGenerateTaskPipeline._application_generate_entity` overrides parent class `BasedGenerateTaskPipeline` in an inconsistent manner [bad-override]
--> core/app/task_pipeline/easy_ui_based_generate_task_pipeline.py:75:5
ERROR `+=` is not supported between `list[PromptMessageContentUnionTypes]` and `str` [unsupported-operation]
@@ -2117,11 +2119,11 @@
ERROR Argument `list[dict[str, Any]] | None` is not assignable to parameter `obj` with type `Sized` in function `len` [bad-argument-type]
--> tests/unit_tests/controllers/service_api/app/test_completion.py:156:20
ERROR Argument value `Literal[0]` violates Pydantic `ge` constraint `Literal[1]` for field `limit` [bad-argument-type]
- --> tests/unit_tests/controllers/service_api/app/test_conversation.py:80:35
+ --> tests/unit_tests/controllers/service_api/app/test_conversation.py:84:35
ERROR Argument value `Literal[101]` violates Pydantic `le` constraint `Literal[100]` for field `limit` [bad-argument-type]
- --> tests/unit_tests/controllers/service_api/app/test_conversation.py:85:35
+ --> tests/unit_tests/controllers/service_api/app/test_conversation.py:89:35
ERROR Missing argument `session` in function `services.conversation_service.ConversationService.pagination_by_last_id` [missing-argument]
- --> tests/unit_tests/controllers/service_api/app/test_conversation.py:383:59
+ --> tests/unit_tests/controllers/service_api/app/test_conversation.py:427:59
ERROR Argument value `Literal[0]` violates Pydantic `ge` constraint `Literal[1]` for field `limit` [bad-argument-type]
--> tests/unit_tests/controllers/service_api/app/test_message.py:94:63
ERROR Argument value `Literal[101]` violates Pydantic `le` constraint `Literal[100]` for field `limit` [bad-argument-type]
|
asukaminato0721
approved these changes
Apr 14, 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.
Part of #28015
Summary
Migrate service API conversation-variable response serialization from Flask-RESTX
@marshal_with(...)to PydanticBaseModelresponse classes. Add schema models for variable item/pagination responses and preserve output behavior by normalizingvalue_typeand datetime fields.Checklist
make lintandmake type-check(backend) andcd web && pnpm exec vp staged(frontend) to appease the lint gods