Skip to content

fix(config): a config read quotes no text of a bad YAML file - #3552

Merged
dan-petty merged 3 commits into
mainfrom
fix/2451-config-yaml-load-error-hides-text
Nov 5, 2026
Merged

dan-petty merged 3 commits into
mainfrom
fix/2451-config-yaml-load-error-hides-text

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

A config file can hold a credential. Three paths read it without the settings load, and showed text of it when PyYAML or ruamel.yaml could not load it.

  • write_history._mapping ran yaml.safe_load. ruamel.yaml accepts a local tag such as !vault, so devops config unset reached PyYAML, and its error quoted the line with the value.
  • round_trip.find and edit caught only ruamel.yaml.YAMLError. !!int and !!bool raised ValueError and KeyError with the value in the message.

New config/yaml_errors.py::load_yaml raises one ConfigurationError. It names the file, the type of the error, and the line and column when the error has a mark. It quotes no text, and has no cause and no context. The settings load, the audit record, the redaction and the round trip use it.

Closes #2451

Change: openspec/changes/archive/2026-11-04-2451-config-yaml-load-error-hides-text/

@dan-petty dan-petty added type/bug Type bug: the code does not do what it must scope/config Settings, OS Keyring, environment variables, and defaults labels Nov 5, 2026
@dan-petty

Copy link
Copy Markdown
Owner Author

Test results.

  • fail-to-pass (devops ci fail-to-pass --base origin/main): 3 tests of test_config_key_removal.py fail on base. test_config_yaml_load_errors.py errors on base because config/yaml_errors.py does not exist there.
  • Local: tests/config, tests/commands/test_config_audit_keys.py and tests/commands/test_config.py pass (267 tests). devops ci passed all gates except security (one bandit B108 for a /tmp string in my test, fixed in the next commit) and the test budget (6m 50s, caused by other slow tests).
  • Premise: on base, devops config unset stops before it writes, so the file and its audit record stay as they were. audit-keys already handled !!bool (fix(config): a config file that does not parse never prints its line from any command that loads settings #1468). The issue text was partly out of date.

@dan-petty
dan-petty marked this pull request as ready for review November 5, 2026 00:12
@dan-petty
dan-petty merged commit a99d1a6 into main Nov 5, 2026
23 checks passed
@dan-petty
dan-petty deleted the fix/2451-config-yaml-load-error-hides-text branch November 5, 2026 00:13
dan-petty pushed a commit that referenced this pull request Nov 5, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.57.1](v0.57.0...v0.57.1)
(2026-11-05)


### Bug Fixes

* **config:** a config read quotes no text of a bad YAML file
([#3552](#3552))
([a99d1a6](a99d1a6))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: dan-petty-release[bot] <346998822+dan-petty-release[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope/config Settings, OS Keyring, environment variables, and defaults type/bug Type bug: the code does not do what it must

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(config): a config write or audit shows text of a config file that PyYAML or ruamel.yaml cannot load

1 participant