Conversation
When using KEY=@filepath, file contents included trailing newlines which most files have by default. Use strings.TrimRight to strip \r\n from the end of file-read values.
📝 WalkthroughWalkthroughThis change modifies how environment variables loaded from files are processed. When an environment variable is specified using the 📝 Coding Plan
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
cli/commands/env_test.go (1)
80-97: LGTM!Good test coverage for the trailing newline trimming behavior. The test input
"\r\n\n"exercises both CR and LF character trimming.Optionally, consider adding edge case tests for completeness:
- File containing only newlines (should result in empty string)
- File with internal newlines like
"line1\nline2\n"(should preserve internal, trim trailing)These can be deferred if the current coverage is sufficient for the use case.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@cli/commands/env_test.go` around lines 80 - 97, Add two additional unit tests for ParseEnvVarSpecs to cover edge cases: one where the temp file contains only newlines (e.g., "\n\r\n") and assert the parsed spec Value is an empty string, and another where the file contains internal newlines (e.g., "line1\nline2\n") and assert internal newlines are preserved while only the trailing newline is trimmed; add these alongside the existing t.Run("trims trailing newlines from file value", ...) test in env_test.go so they exercise the same file-reading/path handling code path.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@cli/commands/env_test.go`:
- Around line 80-97: Add two additional unit tests for ParseEnvVarSpecs to cover
edge cases: one where the temp file contains only newlines (e.g., "\n\r\n") and
assert the parsed spec Value is an empty string, and another where the file
contains internal newlines (e.g., "line1\nline2\n") and assert internal newlines
are preserved while only the trailing newline is trimmed; add these alongside
the existing t.Run("trims trailing newlines from file value", ...) test in
env_test.go so they exercise the same file-reading/path handling code path.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: a5af7337-46e8-48cc-9fbe-faecd1534323
📒 Files selected for processing (2)
cli/commands/env.gocli/commands/env_test.go
Summary
KEY=@filepathto set env vars from files, trailing newlines (\r\n) are now trimmed from the file contentsstrings.TrimRightwith"\r\n"to only strip line endings, preserving intentional leading/trailing spacesFixes MIR-259
Test plan
trims_trailing_newlines_from_file_valuethat writes a file with\r\n\nsuffix and verifies it's trimmedmake test— 3640 tests, 0 failures)