dify - 💡(How to fix) Fix [Refactor/Chore] Improve Service Layer Test Coverage and Fix Discovered Bugs [2 pull requests]

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…

While working on improving the test coverage for modules in the services directory (specifically those with <= 20% coverage), I discovered and fixed two bugs in the business logic.

This issue tracks the effort to both fix these bugs and contribute the full suite of new unit tests, which significantly increases the stability and maintainability of the service layer.

Root Cause

While working on improving the test coverage for modules in the services directory (specifically those with <= 20% coverage), I discovered and fixed two bugs in the business logic.

This issue tracks the effort to both fix these bugs and contribute the full suite of new unit tests, which significantly increases the stability and maintainability of the service layer.

Fix Action

Fixed

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

Summary

While working on improving the test coverage for modules in the services directory (specifically those with <= 20% coverage), I discovered and fixed two bugs in the business logic.

This issue tracks the effort to both fix these bugs and contribute the full suite of new unit tests, which significantly increases the stability and maintainability of the service layer.

Discovered Bugs

  1. Bug in services/app_dsl_service.py:

    • Issue: The AppDslService.import_app method, when using the YAML_CONTENT import mode, lacked content size validation. This was inconsistent with the YAML_URL mode, which already enforced the DSL_MAX_SIZE limit. This could lead to memory pressure, OOM errors, or service hangs when importing oversized YAML content.
    • Fix: Added a consistent content length validation against DSL_MAX_SIZE for the YAML_CONTENT mode.
  2. Bug in services/plugin/plugin_migration.py:

    • Issue: The plugin existence check logic during installation was broken in two ways:
      1. Wrong dictionary access: It used plugins.get(plugin_id) instead of the correct path plugins["plugins"].get(plugin_id).
      2. Reversed condition: It was incorrectly adding already existing plugin IDs to the plugin_not_exist list.
    • Fix: Corrected the dictionary lookup path for the plugin identifier and fixed the logical condition to correctly identify and record only the truly missing plugins.

Plan of Action

To ensure a clear and efficient review process, I will submit two separate Pull Requests:

  1. PR #36072: Will contain the fixes for the two bugs described above, along with their corresponding unit tests (test_app_dsl_service.py and test_plugin_migration.py).
  2. PR #36074: Will submit the remaining unit tests for the other 8 low-coverage service modules.

Both PRs will be linked to this issue for complete tracking.

Motivation

No response

Additional Context

<img width="960" height="441" alt="Image" src="https://github.com/user-attachments/assets/6448da4f-10b4-4266-b5b4-abf70f22b8ff" />

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 - 💡(How to fix) Fix [Refactor/Chore] Improve Service Layer Test Coverage and Fix Discovered Bugs [2 pull requests]