dify - ✅(Solved) Fix Declare Flask as a direct API dependency [1 pull requests, 1 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#35567Fetched 2026-04-26 05:24:35
View on GitHub
Comments
0
Participants
1
Timeline
4
Reactions
1
Author
Participants
Assignees
Timeline (top)
assigned ×1closed ×1cross-referenced ×1labeled ×1

Root Cause

  1. Inspect api/pyproject.toml.
  2. Note that API source files import Flask directly, for example api/app_factory.py and api/dify_app.py.
  3. Check the dependency tree for Flask with uv tree --project api --invert --package flask.
  4. Flask is installed because Flask extensions pull it transitively, but dify-api does not declare Flask directly.

Fix Action

Fixed

PR fix notes

PR #35568: fix(api): declare flask dependency

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

Fixes #35567.

  • Declares flask>=3.1.3,<4.0.0 as a direct API dependency in the Legacy dependency group.
  • Updates api/uv.lock so dify-api directly records Flask in its dependency metadata.
  • Keeps the resolved Flask package unchanged at 3.1.3.

Validation:

  • uv lock --project api
  • uv lock --project api --check
  • uv tree --project api --invert --package flask
  • git diff --check -- api/pyproject.toml api/uv.lock

Screenshots

BeforeAfter
Not applicable: dependency metadata change.Not applicable: dependency metadata change.

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

From Codex

Changed files

  • api/pyproject.toml (modified, +1/-0)
  • api/uv.lock (modified, +2/-0)
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

main / 1.13.3

Cloud or Self Hosted

Self Hosted (Source)

Steps to reproduce

  1. Inspect api/pyproject.toml.
  2. Note that API source files import Flask directly, for example api/app_factory.py and api/dify_app.py.
  3. Check the dependency tree for Flask with uv tree --project api --invert --package flask.
  4. Flask is installed because Flask extensions pull it transitively, but dify-api does not declare Flask directly.

✔️ Expected Behavior

dify-api should declare Flask as a direct dependency because the backend imports and subclasses Flask directly.

❌ Actual Behavior

api/pyproject.toml declares several Flask extensions, but not Flask itself. This makes Flask availability rely on transitive dependencies instead of the backend's explicit runtime contract.

extent analysis

TL;DR

Add Flask as a direct dependency in api/pyproject.toml to ensure its availability.

Guidance

  • Check the current dependencies in api/pyproject.toml to identify any potential conflicts or version issues with Flask.
  • Run uv tree --project api --invert --package flask again after adding Flask as a dependency to verify its presence in the dependency tree.
  • Review the import statements in api/app_factory.py and api/dify_app.py to ensure they are compatible with the version of Flask being added.
  • Consider testing the backend with the updated dependency to ensure no new issues are introduced.

Example

[tool.poetry.dependencies]
flask = "^2.0"

This example assumes the use of Poetry for dependency management, as implied by the pyproject.toml file.

Notes

The fix assumes that the version of Flask being added is compatible with the existing dependencies and the backend code. If issues arise, further investigation into version conflicts or compatibility problems may be necessary.

Recommendation

Apply workaround: Add Flask as a direct dependency in api/pyproject.toml, as this ensures the backend's explicit runtime contract and avoids reliance on transitive dependencies.

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 Declare Flask as a direct API dependency [1 pull requests, 1 participants]