[Chore] Failed unit tests for api with exmaple .env #21678

Open
opened 2026-02-21 20:13:49 -05:00 by yindo · 1 comment
Owner

Originally created by @BeautyyuYanli on GitHub (Jan 15, 2026).

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

Some of the default value of dify config is diff with the example .env, so it causes the units tests failing when the .env presented.

Motivation

No response

Additional Context

No response

Originally created by @BeautyyuYanli on GitHub (Jan 15, 2026). ### Self Checks - [x] I have read the [Contributing Guide](https://github.com/langgenius/dify/blob/main/CONTRIBUTING.md) and [Language Policy](https://github.com/langgenius/dify/issues/1542). - [x] This is only for refactors or chores; if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [x] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [x] I confirm that I am using English to submit this report, otherwise it will be closed. - [x] 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :) - [x] Please do not modify this template :) and fill in all the required fields. ### Description Some of the default value of dify config is diff with the example `.env`, so it causes the units tests failing when the `.env` presented. ### Motivation _No response_ ### Additional Context _No response_
yindo added the stale label 2026-02-21 20:13:49 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Jan 15, 2026):

This is a known and tracked issue—unit test failures can happen because the default config values in code (like DB_HOST=localhost, DB_PASSWORD='', VECTOR_STORE=None, LOG_FILE=None) often differ from the concrete values in the example .env (like DB_HOST=db_postgres, DB_PASSWORD=difyai123456, VECTOR_STORE=weaviate, LOG_FILE=/app/logs/server.log) that are tailored for the Docker stack. This mismatch means tests or services may fail if the environment isn't aligned with what the tests expect [source].

To address this, Dify provides a tool called dify-env-sync.sh (added in PR #29845) that safely syncs your .env file with .env.example while preserving your custom values. It creates timestamped backups, adds new variables, and flags removed ones for manual cleanup. This is the recommended way to keep your environment up to date and avoid config mismatches that break tests [source].

How to use the sync tool:

  1. In the docker directory, run:
    chmod +x dify-env-sync.sh
    ./dify-env-sync.sh
    
  2. Review the output for any warnings about removed or changed variables.
  3. After syncing, restart all Docker containers to apply the changes.

If you still see failures, double-check that critical variables (like DB_HOST, DB_PASSWORD, VECTOR_STORE, LOG_FILE, FILES_URL, INTERNAL_FILES_URL) match the expected values for your test or deployment environment. The project is actively working to improve config consistency, so reviewing recent PRs and the latest .env.example is also a good idea [source].

If you encounter new mismatches or issues after syncing, please report them—this helps keep the environment and code aligned for everyone.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

Chat with Dosu Open in Cursor Join Discord Share on X

@dosubot[bot] commented on GitHub (Jan 15, 2026): <!-- Answer --> This is a known and tracked issue—unit test failures can happen because the default config values in code (like DB_HOST=localhost, DB_PASSWORD='', VECTOR_STORE=None, LOG_FILE=None) often differ from the concrete values in the example `.env` (like DB_HOST=db_postgres, DB_PASSWORD=difyai123456, VECTOR_STORE=weaviate, LOG_FILE=/app/logs/server.log) that are tailored for the Docker stack. This mismatch means tests or services may fail if the environment isn't aligned with what the tests expect [[source]](https://github.com/langgenius/dify/blob/2b021e8752a9b8e18867634f04144859b2f6c8f4/docker/.env.example#L13-L1521). To address this, Dify provides a tool called `dify-env-sync.sh` (added in PR #29845) that safely syncs your `.env` file with `.env.example` while preserving your custom values. It creates timestamped backups, adds new variables, and flags removed ones for manual cleanup. This is the recommended way to keep your environment up to date and avoid config mismatches that break tests [[source]](https://github.com/langgenius/dify/pull/29845). **How to use the sync tool:** 1. In the `docker` directory, run: ```bash chmod +x dify-env-sync.sh ./dify-env-sync.sh ``` 2. Review the output for any warnings about removed or changed variables. 3. After syncing, restart all Docker containers to apply the changes. If you still see failures, double-check that critical variables (like DB_HOST, DB_PASSWORD, VECTOR_STORE, LOG_FILE, FILES_URL, INTERNAL_FILES_URL) match the expected values for your test or deployment environment. The project is actively working to improve config consistency, so reviewing recent PRs and the latest `.env.example` is also a good idea [[source]](https://github.com/langgenius/dify/pull/30516). If you encounter new mismatches or issues after syncing, please report them—this helps keep the environment and code aligned for everyone. <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/03da9df6-3233-410d-a8a7-73b797a84c70?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/03da9df6-3233-410d-a8a7-73b797a84c70?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/03da9df6-3233-410d-a8a7-73b797a84c70?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/03da9df6-3233-410d-a8a7-73b797a84c70?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/03da9df6-3233-410d-a8a7-73b797a84c70?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/03da9df6-3233-410d-a8a7-73b797a84c70?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/03da9df6-3233-410d-a8a7-73b797a84c70?feedback_type=other)</sup> [![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/6088a4f4-073a-43f3-b3d4-4f06fb0c05a0/ask?utm_source=github)&nbsp;[![Open in Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=This%20is%20a%20known%20and%20tracked%20issue%E2%80%94unit%20test%20failures%20can%20happen%20because%20the%20default%20config%20values%20in%20code%20%28like%20DB_HOST%3Dlocalhost%2C%20DB_PASSWORD%3D%27%27%2C%20VECTOR_STORE%3DNone%2C%20LOG_FILE%3DNone%29%20often%20differ%20from%20the%20concrete%20values%20in%20the%20example%20%60.env%60%20%28like%20DB_HOST%3Ddb_postgres%2C%20DB_PASSWORD%3Ddifyai123456%2C%20VECTOR_STORE%3Dweaviate%2C%20LOG_FILE%3D/app/logs/server.log%29%20that%20are%20tailored%20for%20the%20Docker%20stack.%20This%20mismatch%20means%20tests%20or%20services%20may%20fail%20if%20the%20environment%20isn%27t%20aligned%20with%20what%20the%20tests%20expect%20%5B%5Bsource%5D%5D%28https%3A//github.com/langgenius/dify/blob/2b021e8752a9b8e18867634f04144859b2f6c8f4/docker/.env.example%23L13-L1521%29.%0A%0ATo%20address%20this%2C%20Dify%20provides%20a%20tool%20called%20%60dify-env-sync.sh%60%20%28added%20in%20PR%20%2329845%29%20that%20safely%20syncs%20your%20%60.env%60%20file%20with%20%60.env.example%60%20while%20preserving%20your%20custom%20values.%20It%20creates%20timestamped%20backups%2C%20adds%20new%20variables%2C%20and%20flags%20removed%20ones%20for%20manual%20cleanup.%20This%20is%20the%20recommended%20way%20to%20keep%20your%20environment%20up%20to%20date%20and%20avoid%20config%20mismatches%20that%20break%20tests%20%5B%5Bsource%5D%5D%28https%3A//github.com/langgenius/dify/pull/29845%29.%0A%0A%2A%2AHow%20to%20use%20the%20sync%20tool%3A%2A%2A%0A1.%20In%20the%20%60docker%60%20directory%2C%20run%3A%0A%20%20%20%60%60%60bash%0A%20%20%20chmod%20%2Bx%20dify-env-sync.sh%0A%20%20%20./dify-env-sync.sh%0A%20%20%20%60%60%60%0A2.%20Review%20the%20output%20for%20any%20warnings%20about%20removed%20or%20changed%20variables.%0A3.%20After%20syncing%2C%20restart%20all%20Docker%20containers%20to%20apply%20the%20changes.%0A%0AIf%20you%20still%20see%20failures%2C%20double-check%20that%20critical%20variables%20%28like%20DB_HOST%2C%20DB_PASSWORD%2C%20VECTOR_STORE%2C%20LOG_FILE%2C%20FILES_URL%2C%20INTERNAL_FILES_URL%29%20match%20the%20expected%20values%20for%20your%20test%20or%20deployment%20environment.%20The%20project%20is%20actively%20working%20to%20improve%20config%20consistency%2C%20so%20reviewing%20recent%20PRs%20and%20the%20latest%20%60.env.example%60%20is%20also%20a%20good%20idea%20%5B%5Bsource%5D%5D%28https%3A//github.com/langgenius/dify/pull/30516%29.%0A%0AIf%20you%20encounter%20new%20mismatches%20or%20issues%20after%20syncing%2C%20please%20report%20them%E2%80%94this%20helps%20keep%20the%20environment%20and%20code%20aligned%20for%20everyone.)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/langgenius/dify/issues/31064)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#21678