ProxSave v0.13.2
🧾 Config upgrade fidelity, comment/case preservation, and actionable upgrade warnings
This fix release hardens the backup.env parsing and upgrade pipeline to be much more faithful to real-world configs. It improves handling of comments (inline and block), key casing, legacy export prefixes (with arbitrary whitespace), and multiline values, while adding non-fatal warnings that surface potential issues during plan/upgrade runs. The result is safer upgrades with fewer surprises and clearer operator feedback.
- More faithful env rewriting (
SetEnvValue):- Skips commented lines and preserves indentation and inline comments when replacing values.
- Detects and preserves an optional leading
exporttoken, normalizing whitespace (e.g.export FOO=...) instead of dropping it.
- Stronger parsing for real-world env files:
parseEnvFile/parseEnvValuesnow ignores comment-only lines inside multiline block values, and stores comment text alongside parsed values.splitKeyValueRawhandles legacyexportprefixes, extracts quoted/unquoted values more robustly, and returns parsed inline comments.- Normalizes env keys to uppercase for consistent lookups while remaining compatible with legacy/lowercase configs (including multiline and multi-value keys).
- Upgrade logic correctness and no-op detection:
computeConfigUpgradeuses case-insensitive lookups, tracks processed user keys, preserves original user casing for extra keys, and counts preserved values correctly.- Detects no-op upgrades by comparing rendered content to the original file content.
- Ensures case-insensitive handling of block-value keys in the upgrade logic.
- Non-fatal upgrade warnings (surfaced in CLI):
- Added
Warnings []stringto the upgrade result and propagated warnings end-to-end so they print during plan/upgrade operations. - Warns about duplicate template keys that differ only by case, case-collisions between user keys and template keys, and ignored non-
KEY=VALUElines (multiline behavior preserved).
- Added
- New shared parsing utilities + unified behavior:
- Introduced string helpers (
FindInlineCommentIndex,FindClosingQuoteIndex,SetEnvValue) to centralize handling of inline comments, escaped#, and quoted values. - Replaced local
setEnvValueimplementations to use the unified utility function across the codebase.
- Introduced string helpers (
- Legacy
exportwhitespace edge cases fixed:- Export detection now uses a Fields-based parse so
export\t\tKEY=...works correctly and keys likeexporter=...are not misidentified. - Added coverage for tabbed whitespace and multiple spacing variants.
- Export detection now uses a Fields-based parse so
- Preservation tests and regression coverage:
- Added tests verifying inline comments are preserved through upgrades (including quoted
#cases). - Added tests verifying block-style comment lines inside multiline variables are preserved.
- Added tests for lowercase-key normalization across multiline and multi-value accumulation.
- Added tests verifying inline comments are preserved through upgrades (including quoted
- Minor housekeeping:
- Updated internal/orchestrator/.backup.lock (pid/time) as part of the changeset.
Overall: config upgrades are now safer and more predictable—comments and formatting are preserved, casing and legacy export syntax are handled correctly, and potential pitfalls are reported as clear, non-fatal warnings.