Skip to content

Config: Always produce loadable YAML when mutating .herb.yml - #2034

Merged
marcoroth merged 1 commit into
mainfrom
config-mutations-produce-valid-yaml
Aug 6, 2026
Merged

marcoroth merged 1 commit into
mainfrom
config-mutations-produce-valid-yaml

Conversation

@marcoroth

Copy link
Copy Markdown
Owner

This pull request fixes two ways herb-config could write a .herb.yml that no longer loads, and adds a guard so it cannot happen again.

Found while working on #1632, which enables YAML anchors and aliases in .herb.yml. Now that anchors are supported, configs using them flow into the mutation path for the first time, and Yerba has no anchor or alias handling.

Related #1632

@github-actions github-actions Bot added config Herb configuration file handling and config options rust Rust bindings and the Herb Rust crate labels Aug 6, 2026
@marcoroth
marcoroth enabled auto-merge (squash) August 6, 2026 00:31
@marcoroth
marcoroth merged commit 45ad2b5 into main Aug 6, 2026
20 of 21 checks passed
@marcoroth
marcoroth deleted the config-mutations-produce-valid-yaml branch August 6, 2026 00:42
marcoroth added a commit that referenced this pull request Aug 6, 2026
This pull request makes the commands that write to `.herb.yml` report
when the value they changed is aliased elsewhere in the file.

Based on #2034, which stops mutations from writing invalid YAML. This
one covers the case where the write succeeds and the file stays valid,
but changes more than the user asked for.

#### The problem

Writing to a value that carries an anchor also changes every key
aliasing it:

```yaml
version: 0.10.3

linter:
  enabled: &flag true

formatter:
  enabled: *flag
```

Running "Disable Herb Linter" in VS Code writes `enabled: &flag false`,
which disables the formatter too. The file is valid and the result is
what the alias asks for, so the behaviour is left alone. The problem was
that nothing said so, and the effect is invisible unless you reread the
config.


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

Labels

config Herb configuration file handling and config options rust Rust bindings and the Herb Rust crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant