Skip to content

fix(api): use billing quota for credit pool#38132

Open
zyssyz123 wants to merge 5 commits into
hotfix/1.14.2-fix.12from
hotfix-1.14.2-fix.12
Open

fix(api): use billing quota for credit pool#38132
zyssyz123 wants to merge 5 commits into
hotfix/1.14.2-fix.12from
hotfix-1.14.2-fix.12

Conversation

@zyssyz123

Copy link
Copy Markdown
Contributor

Summary

  • Backport credit pool quota deduction to route through the new billing quota APIs.
  • Keep existing credit pool business behavior unchanged, including trial/paid bucket selection.
  • Add/update unit coverage for quota request routing, bucket payloads, capped consume, and credit pool fallback paths.

Notes

Direct push to hotfix/1.14.2-fix.12 is blocked by repository rules, so this PR targets the protected hotfix branch. Once merged, the hotfix/** build workflow should publish langgenius/dify-api:hotfix-1.14.2-fix.12.

Validation

  • api/.venv/bin/python -m py_compile api/services/billing_service.py api/services/credit_pool_service.py api/tests/unit_tests/services/test_billing_service.py api/tests/unit_tests/services/test_credit_pool_service.py
  • api/.venv/bin/ruff check api/services/billing_service.py api/services/credit_pool_service.py api/tests/unit_tests/services/test_billing_service.py api/tests/unit_tests/services/test_credit_pool_service.py
  • Targeted local pytest still exits 139 in this local environment, same as the original PR validation path.

@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Jun 29, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-06-29 02:36:26.665769076 +0000
+++ /tmp/pyrefly_pr.txt	2026-06-29 02:36:14.198609322 +0000
@@ -5906,14 +5906,20 @@
    --> tests/unit_tests/services/test_async_workflow_service.py:322:22
 ERROR Argument `None` is not assignable to parameter `file` with type `FileStorage` in function `services.audio_service.AudioService.transcript_asr` [bad-argument-type]
    --> tests/unit_tests/services/test_audio_service.py:323:61
+ERROR Unexpected keyword argument `exclude_vector_space` in function `services.billing_service.BillingService.get_info` [unexpected-keyword]
+   --> tests/unit_tests/services/test_billing_service.py:353:53
+ERROR Unexpected keyword argument `exclude_vector_space` in function `services.billing_service.BillingService.get_info` [unexpected-keyword]
+   --> tests/unit_tests/services/test_billing_service.py:384:53
+ERROR Class `BillingService` has no class attribute `get_vector_space` [missing-attribute]
+   --> tests/unit_tests/services/test_billing_service.py:402:18
 ERROR Argument `BillingInfo` is not assignable to parameter `result` with type `dict[Unknown, Unknown]` in function `TestBillingServiceSubscriptionInfoDataType._assert_billing_info_types` [bad-argument-type]
-    --> tests/unit_tests/services/test_billing_service.py:1771:41
+    --> tests/unit_tests/services/test_billing_service.py:1964:41
 ERROR Argument `BillingInfo` is not assignable to parameter `result` with type `dict[Unknown, Unknown]` in function `TestBillingServiceSubscriptionInfoDataType._assert_billing_info_types` [bad-argument-type]
-    --> tests/unit_tests/services/test_billing_service.py:1780:41
+    --> tests/unit_tests/services/test_billing_service.py:1973:41
 ERROR Argument `BillingInfo` is not assignable to parameter `result` with type `dict[Unknown, Unknown]` in function `TestBillingServiceSubscriptionInfoDataType._assert_billing_info_types` [bad-argument-type]
-    --> tests/unit_tests/services/test_billing_service.py:1791:41
+    --> tests/unit_tests/services/test_billing_service.py:1984:41
 ERROR Argument `BillingInfo` is not assignable to parameter `result` with type `dict[Unknown, Unknown]` in function `TestBillingServiceSubscriptionInfoDataType._assert_billing_info_types` [bad-argument-type]
-    --> tests/unit_tests/services/test_billing_service.py:1802:41
+    --> tests/unit_tests/services/test_billing_service.py:1995:41
 ERROR Argument `FakeRepo` is not assignable to parameter `workflow_run_repo` with type `APIWorkflowRunRepository | None` in function `services.retention.workflow_run.clear_free_plan_expired_workflow_run_logs.WorkflowRunCleanup.__init__` [bad-argument-type]
    --> tests/unit_tests/services/test_clear_free_plan_expired_workflow_run_logs.py:114:49
 ERROR Class member `FixedDateTime.now` overrides parent class `datetime` in an inconsistent manner [bad-override]
@@ -5921,13 +5927,13 @@
 ERROR Class member `FixedDateTime.now` overrides parent class `datetime` in an inconsistent manner [bad-override]
    --> tests/unit_tests/services/test_clear_free_plan_tenant_expired_logs.py:478:13
 ERROR Object of class `FromClause` has no attribute `create` [missing-attribute]
-  --> tests/unit_tests/services/test_credit_pool_service.py:24:5
+  --> tests/unit_tests/services/test_credit_pool_service.py:26:5
 ERROR Object of class `FromClause` has no attribute `insert` [missing-attribute]
-  --> tests/unit_tests/services/test_credit_pool_service.py:29:13
+  --> tests/unit_tests/services/test_credit_pool_service.py:31:13
 ERROR Object of class `FromClause` has no attribute `create` [missing-attribute]
-  --> tests/unit_tests/services/test_credit_pool_service.py:94:5
+   --> tests/unit_tests/services/test_credit_pool_service.py:109:5
 ERROR Object of class `FromClause` has no attribute `create` [missing-attribute]
-   --> tests/unit_tests/services/test_credit_pool_service.py:146:5
+   --> tests/unit_tests/services/test_credit_pool_service.py:161:5
 ERROR Argument `SimpleNamespace` is not assignable to parameter `account` with type `Account` in function `services.dataset_service.DatasetService.create_empty_dataset` [bad-argument-type]
    --> tests/unit_tests/services/test_dataset_service_dataset.py:180:93
 ERROR Argument `SimpleNamespace` is not assignable to parameter `account` with type `Account` in function `services.dataset_service.DatasetService.create_empty_dataset` [bad-argument-type]

@github-actions

Copy link
Copy Markdown
Contributor

Pyrefly Type Coverage

Metric Base PR Delta
Type coverage 44.42% 44.43% +0.01%
Strict coverage 43.94% 43.95% +0.01%
Typed symbols 22,542 22,566 +24
Untyped symbols 28,511 28,529 +18
Modules 2561 2561 0

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

Labels

size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant