dify - ✅(Solved) Fix Iteration block fails with 'Working outside of application context error' when parallel mode is enabled in Dify 1.14.1 [1 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
langgenius/dify#36132Fetched 2026-05-14 03:46:31
View on GitHub
Comments
1
Participants
2
Timeline
9
Reactions
1
Assignees
Timeline (top)
labeled ×2assigned ×1closed ×1commented ×1

Error Message

Parallel mode works with no error

PR fix notes

PR #36143: fix: credit pool access outside flask context

Description (problem / solution / changelog)

[!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

<!-- Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change. --> <!-- If this PR was created by an automated agent, add `From <Tool Name>` as the final line of the description. Example: `From Codex`. -->

fix https://github.com/langgenius/dify/issues/36132

error logs:

Traceback (most recent call last):\n  File \"/app/api/.venv/lib/python3.12/site-packages/graphon/graph/graph.py\", line 161, in _create_node_instances\n    node_instance = node_factory.create_node(node_config)\n                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File \"/app/api/core/workflow/node_factory.py\", line 443, in create_node\n    node_init_kwargs = node_init_kwargs_factories.get(node_type, lambda: {})()\n                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File \"/app/api/core/workflow/node_factory.py\", line 398, in <lambda>\n    BuiltinNodeTypes.LLM: lambda: self._build_llm_compatible_node_init_kwargs(\n                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File \"/app/api/core/workflow/node_factory.py\", line 480, in _build_llm_compatible_node_init_kwargs\n    model_instance = self._build_model_instance_for_llm_node(validated_node_data)\n                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File \"/app/api/core/workflow/node_factory.py\", line 508, in _build_model_instance_for_llm_node\n    model_instance, _ = fetch_model_config(\n                        ^^^^^^^^^^^^^^^^^^^\n  File \"/app/api/core/app/llm/model_access.py\", line 141, in fetch_model_config\n    credentials = credentials_provider.fetch(node_data_model.provider, node_data_model.name)\n                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File \"/app/api/core/app/llm/model_access.py\", line 53, in fetch\n    provider_configurations = self.provider_manager.get_configurations(self.tenant_id)\n                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File \"/app/api/core/provider_manager.py\", line 230, in get_configurations\n    system_configuration = self._to_system_configuration(tenant_id, provider_entity, provider_records)\n                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File \"/app/api/core/provider_manager.py\", line 958, in _to_system_configuration\n    trail_pool = CreditPoolService.get_pool(\n                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File \"/app/api/services/credit_pool_service.py\", line 44, in get_pool\n    with sessionmaker(db.engine, expire_on_commit=False).begin() as session:\n                      ^^^^^^^^^\n  File \"/app/api/.venv/lib/python3.12/site-packages/flask_sqlalchemy/extension.py\", line 709, in engine\n    return self.engines[None]\n           ^^^^^^^^^^^^\n  File \"/app/api/.venv/lib/python3.12/site-packages/flask_sqlalchemy/extension.py\", line 687, in engines\n    app = current_app._get_current_object()  # type: ignore[attr-defined]\n          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File \"/app/api/.venv/lib/python3.12/site-packages/werkzeug/local.py\", line 519, in _get_current_object\n    raise RuntimeError(unbound_message) from None\nRuntimeError: Working outside of application context.\n\nThis typically means that you attempted to use functionality that needed\nthe current application. To solve this, set up an application context\nwith app.app_context(). See the documentation for more information.\n

Screenshots

BeforeAfter
......

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

Changed files

  • api/services/credit_pool_service.py (modified, +5/-4)
  • api/tests/unit_tests/core/app/test_llm_quota.py (modified, +12/-1)
  • api/tests/unit_tests/events/test_update_provider_when_message_created.py (modified, +12/-1)
  • api/tests/unit_tests/services/test_credit_pool_service.py (modified, +31/-11)
RAW_BUFFERClick to expand / collapse

Self Checks

  • I have read the Contributing Guide and Language Policy.
  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report, otherwise it will be closed.
  • 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

1.14.1

Cloud or Self Hosted

Cloud

Steps to reproduce

See minimal failing.yml dsl attached

✔️ Expected Behavior

Parallel mode works with no error

❌ Actual Behavior

<img width="387" height="266" alt="Image" src="https://github.com/user-attachments/assets/304aa0b7-bc31-4a5c-b520-bcea4fd58a9d" />

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

dify - ✅(Solved) Fix Iteration block fails with 'Working outside of application context error' when parallel mode is enabled in Dify 1.14.1 [1 pull requests, 1 comments, 2 participants]