Skip to content

refactor: cleanup duplicate code#36173

Merged
asukaminato0721 merged 1 commit into
langgenius:mainfrom
cqjjjzr:duplicate-clean
May 14, 2026
Merged

refactor: cleanup duplicate code#36173
asukaminato0721 merged 1 commit into
langgenius:mainfrom
cqjjjzr:duplicate-clean

Conversation

@cqjjjzr
Copy link
Copy Markdown
Contributor

@cqjjjzr cqjjjzr commented May 14, 2026

Important

  1. Make sure you have read our contribution guidelines
  2. Ensure there is an associated issue and you have been assigned to it
  3. Use the correct syntax to link this PR: Fixes #<issue number>.

Summary

Fix 36171.

Consolidated duplicated API helper logic by:

  1. moving repeated timestamp normalization into libs.helper.to_timestamp
  2. sharing human-input default value serialization
  3. extracting common DSL version compatibility checks
  4. replaced duplicate trigger refresh timestamp helpers with libs.helper.current_timestamp

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 && 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 May 14, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 14, 2026

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-05-14 10:26:43.316131764 +0000
+++ /tmp/pyrefly_pr.txt	2026-05-14 10:26:31.596198234 +0000
@@ -1,7 +1,7 @@
 ERROR `str` is not assignable to `Literal['advanced-chat', 'agent-chat', 'all', 'channel', 'chat', 'completion', 'workflow']` [bad-assignment]
   --> controllers/console/app/app.py:70:104
 ERROR Object of class `App` has no attribute `access_mode` [missing-attribute]
-   --> controllers/console/app/app.py:590:13
+   --> controllers/console/app/app.py:584:13
 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:73:108
 ERROR Object of class `MissingRouter` has no attribute `get` [missing-attribute]
@@ -861,15 +861,15 @@
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
    --> tests/test_containers_integration_tests/services/test_app_dsl_service.py:161:42
 ERROR Argument `Literal['simple']` is not assignable to parameter `prompt_type` with type `PromptType | SQLCoreOperations[PromptType]` in function `models.model.AppModelConfig.__init__` [bad-argument-type]
-   --> tests/test_containers_integration_tests/services/test_app_dsl_service.py:920:25
+   --> tests/test_containers_integration_tests/services/test_app_dsl_service.py:923:25
 ERROR Argument `Literal['workflow']` is not assignable to parameter `value` with type `AppMode | SQLCoreOperations[AppMode]` in function `sqlalchemy.orm.base.Mapped.__set__` [bad-argument-type]
-   --> tests/test_containers_integration_tests/services/test_app_dsl_service.py:943:20
+   --> tests/test_containers_integration_tests/services/test_app_dsl_service.py:946:20
 ERROR Argument `Literal['workflow']` is not assignable to parameter `value` with type `AppMode | SQLCoreOperations[AppMode]` in function `sqlalchemy.orm.base.Mapped.__set__` [bad-argument-type]
-   --> tests/test_containers_integration_tests/services/test_app_dsl_service.py:978:20
+   --> tests/test_containers_integration_tests/services/test_app_dsl_service.py:981:20
 ERROR Argument `Literal['workflow']` is not assignable to parameter `value` with type `AppMode | SQLCoreOperations[AppMode]` in function `sqlalchemy.orm.base.Mapped.__set__` [bad-argument-type]
-    --> tests/test_containers_integration_tests/services/test_app_dsl_service.py:1019:20
+    --> tests/test_containers_integration_tests/services/test_app_dsl_service.py:1022:20
 ERROR Argument `list[SimpleNamespace]` is not assignable to parameter `dsl_dependencies` with type `list[PluginDependency]` in function `services.app_dsl_service.AppDslService.get_leaked_dependencies` [bad-argument-type]
-    --> tests/test_containers_integration_tests/services/test_app_dsl_service.py:1305:73
+    --> tests/test_containers_integration_tests/services/test_app_dsl_service.py:1308:73
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
    --> tests/test_containers_integration_tests/services/test_app_generate_service.py:188:38
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]

@github-actions
Copy link
Copy Markdown
Contributor

Pyrefly Type Coverage

Metric Base PR Delta
Type coverage 0.00% 43.69% +43.69%
Strict coverage 0.00% 43.21% +43.21%
Typed symbols 0 22,038 +22,038
Untyped symbols 0 28,717 +28,717
Modules 0 2553 +2,553

@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label May 14, 2026
@asukaminato0721 asukaminato0721 added this pull request to the merge queue May 14, 2026
Merged via the queue into langgenius:main with commit a35b28d May 14, 2026
27 checks passed
zhangtaodemama added a commit to zhangtaodemama/langgenius-dify-bfaadcb0c706 that referenced this pull request May 14, 2026
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.

2 participants