dify - ✅(Solved) Fix [Refactor/Chore] Split merged API test modules and remove masked F811 violations [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#35104Fetched 2026-04-14 05:56:39
View on GitHub
Comments
0
Participants
1
Timeline
3
Reactions
1
Author
Participants
Assignees
Timeline (top)
assigned ×1closed ×1cross-referenced ×1

Split merged backend test modules back into dedicated files, remove duplicate test definitions/imports introduced by file merging, and stop masking F811 violations under api/tests.

Error Message

  • Local pytest is currently blocked before collection by an existing NumPy/pyarrow ABI mismatch and a DEBUG='release' config parsing error in the test environment.

Root Cause

Split merged backend test modules back into dedicated files, remove duplicate test definitions/imports introduced by file merging, and stop masking F811 violations under api/tests.

Fix Action

Fixed

PR fix notes

PR #35105: test: split merged API test modules and remove F811 ignore

Description (problem / solution / changelog)

Summary

Fixes #35104

  • split merged backend test blocks back into dedicated modules and regroup the additional cases by responsibility
  • remove direct duplicate test definitions and redundant mock rebinding that previously triggered F811
  • drop the broad F811 ignore from api/.ruff.toml now that the affected test files are cleaned up
  • verify the touched files with Ruff and confirm uv run --project api ruff check api/tests --select F811 passes

pytest could not be started locally because the existing environment fails during test bootstrap:

  • pyarrow/pandas is incompatible with the installed NumPy 2.4.4
  • DEBUG='release' fails DifyConfig boolean parsing during api/tests/conftest.py import

From Codex

Screenshots

BeforeAfter
N/AN/A

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/.ruff.toml (modified, +0/-2)
  • api/tests/unit_tests/controllers/service_api/app/test_audio.py (modified, +0/-24)
  • api/tests/unit_tests/controllers/web/test_message_endpoints.py (modified, +0/-6)
  • api/tests/unit_tests/services/test_async_workflow_service.py (modified, +0/-5)
  • api/tests/unit_tests/services/test_model_provider_service.py (added, +602/-0)
  • api/tests/unit_tests/services/test_model_provider_service_sanitization.py (modified, +0/-641)
  • api/tests/unit_tests/services/test_variable_truncator.py (modified, +0/-227)
  • api/tests/unit_tests/services/test_variable_truncator_additional.py (added, +174/-0)
  • api/tests/unit_tests/services/test_webhook_service.py (modified, +0/-768)
  • api/tests/unit_tests/services/test_webhook_service_additional.py (added, +671/-0)
  • api/tests/unit_tests/services/test_workflow_run_service.py (added, +262/-0)
  • api/tests/unit_tests/services/test_workflow_run_service_pause.py (modified, +0/-297)
  • api/tests/unit_tests/services/workflow/test_workflow_event_snapshot_service.py (modified, +0/-575)
  • api/tests/unit_tests/services/workflow/test_workflow_event_snapshot_service_additional.py (added, +505/-0)
RAW_BUFFERClick to expand / collapse

Self Checks

  • I have read the Contributing Guide and Language Policy.
  • This is only for refactors or chores; 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.

Description

Split merged backend test modules back into dedicated files, remove duplicate test definitions/imports introduced by file merging, and stop masking F811 violations under api/tests.

Motivation

The current merged test files make ownership and scope harder to follow, and the broad Ruff ignore for F811 hides real duplicate definitions in tests. Splitting the merged blocks back into dedicated modules restores clearer structure and makes linting signal actionable again.

Additional Context

  • Moved merged blocks into dedicated modules for model provider, workflow run service, webhook service, variable truncator, and workflow event snapshot service tests.
  • Removed direct duplicate definitions in test_audio.py and test_message_endpoints.py, and removed redundant mock aliases in test_async_workflow_service.py.
  • Removed the test-wide F811 ignore from api/.ruff.toml after cleaning the affected test modules.
  • Verified uv run --project api ruff check api/tests --select F811.
  • Local pytest is currently blocked before collection by an existing NumPy/pyarrow ABI mismatch and a DEBUG='release' config parsing error in the test environment.

extent analysis

TL;DR

Splitting merged backend test modules into dedicated files and removing duplicate test definitions can resolve issues with ownership, scope, and linting.

Guidance

  • Verify that all merged test blocks have been correctly split into dedicated modules for each service (e.g., model provider, workflow run service).
  • Check for any remaining duplicate definitions or imports in the newly created test files.
  • Run uv run --project api ruff check api/tests --select F811 to ensure that the F811 violations are properly reported after removing the ignore rule.
  • Address the existing NumPy/pyarrow ABI mismatch and DEBUG='release' config parsing error to unblock local pytest runs.

Example

No specific code snippet is provided as the issue focuses on structural changes to the test modules.

Notes

The provided information suggests that the issue is related to test module structure and linting, but there are additional errors (NumPy/pyarrow ABI mismatch and config parsing error) that need to be addressed separately to fully resolve the problem.

Recommendation

Apply the workaround by splitting the test modules and addressing the additional errors, as there is no clear indication of a fixed version to upgrade to. This approach allows for a step-by-step resolution of the issues while ensuring that the test environment is properly configured.

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