[GH-ISSUE #737] Trailing newline at the end of ***_FILE env variable #5117

Closed
opened 2026-04-22 00:23:01 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @warthan07 on GitHub (Aug 16, 2025).
Original GitHub issue: https://github.com/moghtech/komodo/issues/737

When using ***_FILE environment variables for use with docker secrets, the read variable will include a trailing newline character if the associated file also includes a trailing end-of-file newline (for example, saving the file in neovim by default will always include such a newline character, for POSIX compliance I think). This can break things, for example when connecting to the mongo database which will not expect such newline characters in the username and/or password.

If this is intended behaviour, I think a warning should be mentioned somewhere in the docs that docker secret files should not include such trailing newline characters (for example with a redirection to the file using echo -n).

If this is not intended behaviour, maybe one could modify the maybe_read_item_from_file function from komodo/lib/environment_file/src/lib.rs to remove ending newline characters if found? I think most docker packages I am using always strip such newline characters when reading secret files.

In any case, thanks for the excellent software!

Originally created by @warthan07 on GitHub (Aug 16, 2025). Original GitHub issue: https://github.com/moghtech/komodo/issues/737 When using ***_FILE environment variables for use with docker secrets, the read variable will include a trailing newline character if the associated file also includes a trailing end-of-file newline (for example, saving the file in neovim by default will always include such a newline character, for POSIX compliance I think). This can break things, for example when connecting to the mongo database which will not expect such newline characters in the username and/or password. If this is intended behaviour, I think a warning should be mentioned somewhere in the docs that docker secret files should not include such trailing newline characters (for example with a redirection to the file using echo -n). If this is not intended behaviour, maybe one could modify the maybe_read_item_from_file function from komodo/lib/environment_file/src/lib.rs to remove ending newline characters if found? I think most docker packages I am using always strip such newline characters when reading secret files. In any case, thanks for the excellent software!
Author
Owner

@mbecker20 commented on GitHub (Aug 17, 2025):

Good catch, fixed in this commit which will be included in upcoming v1.19.0 release.

<!-- gh-comment-id:3194147077 --> @mbecker20 commented on GitHub (Aug 17, 2025): Good catch, fixed in this commit which will be included in upcoming v1.19.0 release.
Author
Owner

@warthan07 commented on GitHub (Aug 17, 2025):

Perfect, thanks!

<!-- gh-comment-id:3194170490 --> @warthan07 commented on GitHub (Aug 17, 2025): Perfect, thanks!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/komodo#5117