Skip to content

refactor(api): centralize API key management - #42489

Open
41tair wants to merge 3 commits into
langgenius:mainfrom
41tair:refactor/api-052
Open

41tair wants to merge 3 commits into
langgenius:mainfrom
41tair:refactor/api-052

Conversation

@41tair

@41tair 41tair commented Sep 18, 2026

Copy link
Copy Markdown
Member

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

part of #39993

Screenshots

Before After
... ...

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 verified the change and added or updated tests where meaningful regression risk justifies coverage.
  • I've updated the documentation accordingly.
  • I ran make lint && make type-check (backend) and vp staged (frontend) to appease the lint gods

@github-actions

github-actions Bot commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-09-18 06:09:45.447703396 +0000
+++ /tmp/pyrefly_pr.txt	2026-09-18 06:09:37.147660365 +0000
@@ -1809,29 +1809,29 @@
 ERROR No attribute `MethodView` in module `builtins` [missing-attribute]
  --> tests/unit_tests/controllers/common/test_fields.py:8:5
 ERROR `in` is not supported between `Literal['Incorrect API key provided']` and `None` [not-iterable]
-    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:1748:12
+    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:1684:12
 ERROR `in` is not supported between `Literal['Start a new conversation']` and `None` [not-iterable]
-    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:1780:12
+    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:1716:12
 ERROR Argument `test_drain_streaming_generate_response_returns_on_message_end.ClosableResponse` is not assignable to parameter `response` with type `Generator[str] | RateLimitGenerator` in function `controllers.console.app.completion._drain_streaming_generate_response` [bad-argument-type]
-    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:1903:69
+    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:1839:69
 ERROR Argument `Iterator[str]` is not assignable to parameter `response` with type `Generator[str] | RateLimitGenerator` in function `controllers.console.app.completion._drain_streaming_generate_response` [bad-argument-type]
-    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:1910:66
+    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:1846:66
 ERROR Argument `Iterator[str]` is not assignable to parameter `response` with type `Generator[str] | RateLimitGenerator` in function `controllers.console.app.completion._drain_streaming_generate_response` [bad-argument-type]
-    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:1916:66
+    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:1852:66
 ERROR Object of class `object` has no attribute `data` [missing-attribute]
-    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:2338:50
+    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:2274:50
 ERROR Object of class `object` has no attribute `limit` [missing-attribute]
-    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:2339:30
+    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:2275:30
 ERROR Object of class `object` has no attribute `has_more` [missing-attribute]
-    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:2340:33
+    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:2276:33
 ERROR Object of class `object` has no attribute `data` [missing-attribute]
-    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:2383:50
+    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:2319:50
 ERROR Object of class `object` has no attribute `limit` [missing-attribute]
-    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:2384:30
+    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:2320:30
 ERROR Object of class `object` has no attribute `has_more` [missing-attribute]
-    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:2385:33
+    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:2321:33
 ERROR Argument `Literal['00000000-0000-0000-0000-000000000002']` is not assignable to parameter `message_id` with type `UUID` in function `controllers.console.app.message._get_message_suggested_questions` [bad-argument-type]
-    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:2487:24
+    --> tests/unit_tests/controllers/console/agent/test_agent_controllers.py:2423:24
 ERROR Object of class `int` has no attribute `lower` [missing-attribute]
    --> tests/unit_tests/controllers/console/app/test_annotation_security.py:237:38
 ERROR Object of class `int` has no attribute `lower` [missing-attribute]
@@ -1925,9 +1925,7 @@
 ERROR Argument `scoped_session[flask_sqlalchemy.session.Session]` is not assignable to parameter `session` with type `sqlalchemy.orm.session.Session` in function `_add_binding` [bad-argument-type]
   --> tests/unit_tests/controllers/console/datasets/test_data_source.py:85:28
 ERROR Missing argument `name` in function `controllers.console.datasets.datasets.DatasetCreatePayload.__init__` [missing-argument]
-   --> tests/unit_tests/controllers/console/datasets/test_datasets.py:602:49
-ERROR Object of class `NoneType` has no attribute `token` [missing-attribute]
-    --> tests/unit_tests/controllers/console/datasets/test_datasets.py:1528:16
+   --> tests/unit_tests/controllers/console/datasets/test_datasets.py:605:49
 ERROR Argument `Literal['custom']` is not assignable to parameter `mode` with type `ProcessRuleMode | SQLCoreOperations[ProcessRuleMode]` in function `models.dataset.DatasetProcessRule.__init__` [bad-argument-type]
    --> tests/unit_tests/controllers/console/datasets/test_datasets_document.py:246:18
 ERROR Argument `Literal['custom']` is not assignable to parameter `mode` with type `ProcessRuleMode | SQLCoreOperations[ProcessRuleMode]` in function `models.dataset.DatasetProcessRule.__init__` [bad-argument-type]

@github-actions

github-actions Bot commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Pyrefly Type Coverage

Metric Base PR Delta
Type coverage 64.47% 64.59% +0.13%
Strict coverage 64.07% 64.20% +0.13%
Typed symbols 46,688 46,957 +269
Untyped symbols 25,893 25,896 +3
Modules 3419 3441 +22

@autofix-ci
autofix-ci Bot requested a review from crazywoola as a code owner September 18, 2026 05:54
@github-actions github-actions Bot added the web This relates to changes on the web. label Sep 18, 2026
@codecov

codecov Bot commented Sep 18, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.09502% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.48%. Comparing base (6024141) to head (aed2b05).
⚠️ Report is 11 commits behind head on main.

Files with missing lines Patch % Lines
api/fields/api_key_fields.py 87.09% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #42489      +/-   ##
==========================================
+ Coverage   87.40%   87.48%   +0.08%     
==========================================
  Files        5463     5477      +14     
  Lines      315623   316985    +1362     
  Branches    63604    63514      -90     
==========================================
+ Hits       275863   277316    +1453     
+ Misses      34377    34287      -90     
+ Partials     5383     5382       -1     
Flag Coverage Δ
api 87.10% <99.09%> (+0.01%) ⬆️
dify-ui 93.14% <ø> (-0.60%) ⬇️
web 87.94% <ø> (+0.16%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

web This relates to changes on the web.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant