Fix to_nice_yaml scalar corruption in borgmatic hooks#199
Open
ramcq wants to merge 2 commits intoborgbase:masterfrom
Open
Fix to_nice_yaml scalar corruption in borgmatic hooks#199ramcq wants to merge 2 commits intoborgbase:masterfrom
ramcq wants to merge 2 commits intoborgbase:masterfrom
Conversation
) Add a healthchecks scalar URL to the molecule converge playbook and a verify assertion that checks the rendered borgmatic config doesn't contain '...' (YAML document end marker) in the healthchecks value. This catches the bug where to_nice_yaml on a scalar produces "value\n...\n" which corrupts the config. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…#117) Invoking to_nice_yaml on a scalar value generates a two-line YAML document "value\n...\n" which corrupts the value of a hook such as healthchecks which is just a single string URL. Instead of looping over each of the hooks, apply to_nice_yaml to the entire hooks dict in a single invocation. Add width=1000 to prevent PyYAML from wrapping long strings (like URLs) at 80 chars. Fix both config.yaml.j2 (borgmatic >= 1.8) and config_1.7.yaml.j2 (borgmatic < 1.8). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resurrects #118, rebased onto current master. to_nice_yaml applied to a scalar value (like a healthchecks URL) produces "value\n...\n" - the YAML document end marker corrupts the config. The per-hook loop applies to_nice_yaml to each hook value individually, triggering this bug for any scalar hook such as a healthcheck URL.
This fix applies to_nice_yaml to the entire borgmatic_hooks dict in a single invocation, avoiding the scalar case entirely, and extends the width to 1000 to prevent PyYAML wrapping long strings (like URLs) at 80 chars. Fix applied to both config.yaml.j2 (borgmatic >= 1.8) and config_1.7.yaml.j2 (borgmatic < 1.8).
Note: yamllint does not catch this bug: the indented ... is parsed as part of the scalar string, making it syntactically valid but semantically wrong for borgbackup. A molecule verify assertion is included that checks the rendered config does not contain the ... string at the content level.
Fixes #117