Skip to content

fix: handle empty/whitespace LOG_PATH in docker compose#6031

Open
haroldfabla2-hue wants to merge 1 commit intoFlowiseAI:mainfrom
haroldfabla2-hue:fix/log-path-empty-string
Open

fix: handle empty/whitespace LOG_PATH in docker compose#6031
haroldfabla2-hue wants to merge 1 commit intoFlowiseAI:mainfrom
haroldfabla2-hue:fix/log-path-empty-string

Conversation

@haroldfabla2-hue
Copy link

Summary

When LOG_PATH is set to an empty string in docker-compose (e.g. LOG_PATH=${LOG_PATH} with an unset LOG_PATH env var), the Flowise container fails to start with:

Error: ENOENT: no such file or directory, mkdir ''
    at Object.mkdirSync (node:fs:1386:26)

Root Cause

In packages/server/src/utils/config.ts, the nullish coalescing operator ?? only handles undefined and null, but NOT empty strings:

dir: process.env.LOG_PATH ?? path.join(__dirname, '..', '..', 'logs'),

When LOG_PATH= (empty string), ?? returns "" -> mkdirSync("") fails.

Fix

Use optional chaining + trim + logical OR to properly handle empty strings and whitespace-only values:

dir: process.env.LOG_PATH?.trim() || path.join(__dirname, '..', '..', 'logs'),

This ensures that:

  • undefined -> uses default
  • null -> uses default
  • "" (empty) -> uses default
  • " " (whitespace) -> uses default
  • "/valid/path" -> uses provided path

Testing

  1. LOG_PATH= (empty) -> uses default ./logs
  2. LOG_PATH=" " (whitespace) -> uses default
  3. LOG_PATH=/my/path -> uses provided path

Fixes #6030

When LOG_PATH is set to an empty string in docker-compose (e.g.
LOG_PATH=${LOG_PATH} with unset LOG_PATH), mkdirSync('') fails
with ENOENT error.

Fix: use optional chaining + trim + || instead of ??
to properly handle empty strings and whitespace-only values.

Fixes FlowiseAI#6030
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a critical startup failure in the Flowise container when the LOG_PATH environment variable is misconfigured. By enhancing the logic for environment variable parsing, it ensures that the application gracefully handles empty or whitespace-only LOG_PATH values, preventing mkdir errors and defaulting to the intended logging directory, thereby improving application resilience and ease of deployment.

Highlights

  • Fix for LOG_PATH handling: Resolved an issue where the Flowise container failed to start if the LOG_PATH environment variable was set to an empty string or only whitespace in docker-compose.
  • Robust default path assignment: Implemented a more robust logic using optional chaining (?.), trim(), and the logical OR operator (||) to ensure that undefined, null, empty strings, or whitespace-only values for LOG_PATH correctly fall back to the default logging directory.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request addresses a startup failure that occurs when the LOG_PATH environment variable is set to an empty string. The proposed change correctly handles undefined, null, empty, and whitespace-only values for LOG_PATH by using a default directory as a fallback. The implementation is clean, idiomatic, and effectively resolves the bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Docker Compose setup result in container with "Error: ENOENT: no such file or directory, mkdir ''" error

1 participant