Skip to content

fix(config): read each config file as YAML 1.2 - #4858

Merged
dan-petty merged 9 commits into
mainfrom
fix/4481-read-config-as-yaml-1-2
Nov 12, 2026
Merged

dan-petty merged 9 commits into
mainfrom
fix/4481-read-config-as-yaml-1-2

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

A settings save writes a config file as YAML 1.2 (ruamel.yaml), but each reader read it with PyYAML as YAML 1.1. YAML 1.1 reads a bare off, on, yes or no as a bool and 12:30 as 750. So devops config set roadmap.intake.jev off wrote jev: off, and the next settings load stopped.

Each reader of a config file now uses parse_config_yaml, the YAML 1.2 safe loader of ruamel.yaml: the settings load, the write record, devops config audit-keys, the ConfigMap template config and the SSH key prefix. load_yaml catches the ruamel.yaml errors and has no errors parameter. A duplicate key now stops the load with the file, line and column. Only a bare true or false is a bool. The documents state the YAML 1.2 read.

Closes #4481

Change: openspec/changes/archive/2026-11-11-4481-read-each-config-file-as-yaml/

@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 11, 2026
@dan-petty

Copy link
Copy Markdown
Owner Author

Test record

All runs are local, in the worktree of this branch. The required CI checks of this pull request are the merge gate.

Check Command Result
Static rows uv run devops ci --check --only lint,format,docs,constructs,openspec,test-settings,test-tree,startup-imports,swallowed-failures All 9 rows pass (exit 0)
Tests of the changed modules (22 files) uv run devops ci test tests/commands/test_config.py tests/commands/test_config_audit_keys.py tests/commands/test_config_workspace_docs_dry_run.py tests/config/... tests/crypto/test_ssh.py tests/k8s/test_k8s_configmap.py tests/k8s/test_k8s_configmap_keys.py tests/docs/test_docs.py 407 passed
Types uv run mypy on the 8 changed source files No issues
Knowledge page tests uv run devops ci test tests/ai/test_kb.py tests/review/test_kb_manuals_metadata.py tests/ai/rag/test_knowledge_base_sync.py tests/docs/test_docs.py 76 passed
Docs and OpenSpec after the knowledge page edit uv run devops ci --check --only docs,openspec Pass
After the last rebase onto main uv run devops docs generate --check, uv run devops ci test tests/docs/test_docs.py Up to date, 47 passed
Pre-push uv run devops ci --check --only lint,format, and the pre-push hook Pass

The full gate, --only test, --only security and --only typecheck did not run locally: the host has one gate slot, and the CI checks of this pull request run them.

The main rebase changed docs/roadmap/intake.md and src/devops_cli/docs/generator.py on other lines. The rebase had no conflict, and the docs tests pass after it.

Fail-to-pass

uv run devops ci fail-to-pass --base origin/main exits 0. It ran on the final code of the fix. The later commits change only documents and the OpenSpec archive.

  errored on base: tests.config.test_config_yaml_load_errors (collection failure)
  failed on base: tests.k8s.test_k8s_configmap::test_a_bare_off_in_the_template_renders_a_config_whose_yaml_1_2_read_is_off (pydantic_core._pydantic_core.ValidationError: 1 validation error for Settings)
  failed on base: tests.commands.test_config_audit_keys::test_config_audit_keys_finds_a_credential_whose_bare_value_yaml_1_1_reads_as_false (AssertionError: assert (0, True, []) == (1, False, ['...:ai.api_key']))
  failed on base: tests.commands.test_config_audit_keys::test_config_audit_keys_reports_a_global_config_file_that_the_yaml_loader_cannot_load_unaudited[timestamp] (AssertionError: assert 'Could not audit config file <home>/.config/devops-cli/config.yaml: ConstructorError at line 2, column 12' in ['Could not audit config file <ho
  failed on base: tests.config.test_config_file_that_is_not_yaml::test_a_config_file_that_the_yaml_loader_cannot_load_names_its_file_and_quotes_no_text[timestamp] (AssertionError: assert ('Cannot load...', None, None) == ('Cannot load...', None, None))
  failed on base: tests.config.test_config_file_yaml_1_2::test_a_bare_mode_of_the_intake_loads_as_the_mode[on] (pydantic_core._pydantic_core.ValidationError: 1 validation error for Settings)
  failed on base: tests.config.test_config_file_yaml_1_2::test_a_bare_off_for_a_decision_point_loads_as_the_mode_off (pydantic_core._pydantic_core.ValidationError: 1 validation error for Settings)
  failed on base: tests.config.test_config_file_yaml_1_2::test_a_bare_mode_of_the_intake_loads_as_the_mode[off] (pydantic_core._pydantic_core.ValidationError: 1 validation error for Settings)
  failed on base: tests.config.test_config_file_yaml_1_2::test_a_key_that_a_mapping_holds_two_times_stops_the_load_and_quotes_no_text (Failed: DID NOT RAISE ConfigurationError)
  failed on base: tests.config.test_config_write_history::test_a_write_that_only_drops_the_quotes_of_a_value_records_no_changed_key (AssertionError: assert [['k8s.context']] == [[]])
  failed on base: tests.commands.test_config::test_config_set_of_a_word_that_yaml_1_1_reads_as_a_bool_or_a_number_loads_back_as_set[bool-word] (AssertionError: assert (1, 1, '') == (0, 0, 'no\n'))
  failed on base: tests.commands.test_config::test_config_set_of_a_word_that_yaml_1_1_reads_as_a_bool_or_a_number_loads_back_as_set[sexagesimal] (AssertionError: assert (1, 1, '') == (0, 0, '12:30\n'))
  failed on base: tests.commands.test_config::test_config_set_of_a_word_that_yaml_1_1_reads_as_a_bool_or_a_number_loads_back_as_set[mode-off] (AssertionError: assert (1, 1, '') == (0, 0, 'off\n'))
  failed on base: tests.crypto.test_ssh::test_a_bare_no_in_the_project_config_file_is_the_key_prefix (AssertionError: assert 'my_plain_repo' == 'no')
13 failed on base (13 failed and 158 passed in tests/commands/test_config.py, tests/commands/test_config_audit_keys.py, tests/config/test_config_file_that_is_not_yaml.py, tests/config/test_config_file_yaml_1_2.py, tests/config/test_config_write_history.py, tests/config/test_config_yaml_load_errors.py, tests/crypto/test_ssh.py, t

Live steps

None. The census of the committed config inputs (config.example.yaml and the config in k8s/devops/configmap.example.yaml) found 0 of 84 values that change type between the YAML 1.1 and YAML 1.2 reads.

@dan-petty
dan-petty force-pushed the fix/4481-read-config-as-yaml-1-2 branch from 8c48586 to 85ec88c Compare November 11, 2026 23:45
@dan-petty

Copy link
Copy Markdown
Owner Author

Fix round for CI run 43112944745 (Tests & Coverage, shards 1 and 3).

Cause: four tests added a second ai or qdrant key to the config file of the test. PyYAML kept the last value with no message. The YAML 1.2 read refuses a key that a mapping holds two times (DuplicateKeyError), as the change specifies, so the load stopped:

  • tests/ai/test_service_client_configured_urls.py::test_gateway_only_config_routes_all_calls_to_gateway
  • tests/ai/rag/test_qdrant_timeout_setting.py::test_the_qdrant_timeout_is_read_from_the_config_file_and_the_environment
  • tests/ai/rag/test_qdrant_timeout_setting.py::test_each_builder_gives_its_qdrant_client_the_configured_timeout[rag components]
  • tests/ai/rag/test_qdrant_timeout_setting.py::test_each_builder_gives_its_qdrant_client_the_configured_timeout[indexing]

Fix: the two test files now merge their keys into the section of the file through the config fixture. No other test in the run failed, and no other test adds a key that the config file of the floor holds.

Local record on the final code:

  • uv run devops ci test tests/ai/rag/test_qdrant_timeout_setting.py tests/ai/test_service_client_configured_urls.py: 21 passed.
  • uv run ruff check and uv run ruff format --check on the two files: pass.
  • uv run devops ci --check --only lint,format,docs,constructs,openspec,test-settings,test-tree,startup-imports,swallowed-failures: all rows pass.

A settings save writes a config file with ruamel.yaml, which writes YAML 1.2. The readers used PyYAML, which reads YAML 1.1, so a bare off, on, yes, no or 12:30 that a save wrote changed type at the next load and stopped it. Each reader of a config file now reads it with the safe loader of ruamel.yaml.

Refs #4481.
…cond key

The YAML 1.2 read of a config file refuses a key that a mapping holds two times. Two test files added a second ai or qdrant key to the config file of the test, so the load stopped. They now merge their keys into the section of the file through the config fixture.
…gs load

The read of ssh.key_prefix from a project config file caught only a YAML error. A tagged value that the YAML 1.2 loader cannot build, such as !!int <text>, raised ValueError with the value in its message and stopped the command. The read now catches the errors of the settings load, and its try block holds only the read and the parse.
@dan-petty
dan-petty force-pushed the fix/4481-read-config-as-yaml-1-2 branch from c2797eb to 7fc3f07 Compare November 12, 2026 00:56
@dan-petty
dan-petty marked this pull request as ready for review November 12, 2026 01:07
@dan-petty
dan-petty merged commit c3130a3 into main Nov 12, 2026
27 checks passed
@dan-petty
dan-petty deleted the fix/4481-read-config-as-yaml-1-2 branch November 12, 2026 01:07
@dan-petty

Copy link
Copy Markdown
Owner Author

Fix round for CI run 43122317180 (Tests & Coverage, the diff coverage step).

Cause: diff coverage was 88%, under the limit of 90%. The except branch of the SSH key prefix read (src/devops_cli/crypto/ssh_keys.py, lines 59-61) had no test. A test of that branch also showed a defect: the read caught only a YAML error, so a tagged value that the YAML 1.2 loader cannot build, such as !!int <text>, raised ValueError with the value in its message and stopped the command.

Fix:

  • tests/crypto/test_ssh.py::test_a_project_config_file_that_does_not_load_names_no_prefix: a project config file with a key two times, or with a bad tag, gives no prefix, and the log names the error and quotes no text of the file. The bad-tag case failed on the code before the fix with ValueError: invalid literal for int() with base 10: 'FAKE-value'.
  • The read catches yaml_load_errors() and an OSError, as the audit of devops config audit-keys does. Its try block holds only the read and the parse.
  • The spec of the SSH key prefix has a scenario for a file that does not load. The design and the tasks name the change.

Local record on the final code:

  • uv run devops ci test tests/crypto/test_ssh.py: 82 passed. The coverage of ssh_keys.py with this file only: line 61 (a file that holds no mapping) is the one diff line with no hit.
  • uv run devops ci test tests/ai/agents/test_security_sandbox_and_protection.py: 11 passed.
  • uv run mypy src/devops_cli/crypto/ssh_keys.py: no issues.
  • uv run devops ci --check --only lint,format,docs,constructs,openspec,test-settings,test-tree,startup-imports,swallowed-failures: all rows pass.

uv run devops ci fail-to-pass --base origin/main (exit 0):

15 failed on base (15 failed and 179 passed in tests/ai/rag/test_qdrant_timeout_setting.py, tests/ai/test_service_client_configured_urls.py, tests/commands/test_config.py, tests/commands/test_config_audit_keys.py, tests/config/test_config_file_that_is_not_yaml.py, tests/config/test_config_file_yaml_1_2.py, tests/config/test_config_write_history.py, tests/config/test_config_yaml_load_errors.py, tests/crypto/test_ssh.py, tests/k8s/test_k8s_configmap.py; 1 errored).
  failed on base: tests.crypto.test_ssh::test_a_bare_no_in_the_project_config_file_is_the_key_prefix (AssertionError: assert 'my_plain_repo' == 'no')
  failed on base: tests.crypto.test_ssh::test_a_project_config_file_that_does_not_load_names_no_prefix[a key two times] (AssertionError: assert ('fake-value', False) == ('my_plain_repo', False))
  failed on base: tests.crypto.test_ssh::test_a_project_config_file_that_does_not_load_names_no_prefix[a bad tag] (ValueError: invalid literal for int() with base 10: 'FAKE-value')
  failed on base: tests.config.test_config_file_yaml_1_2::test_a_key_that_a_mapping_holds_two_times_stops_the_load_and_quotes_no_text (Failed: DID NOT RAISE ConfigurationError)
  errored on base: tests.config.test_config_yaml_load_errors (collection failure: the test imports yaml_load_errors, which main does not have)

The owner merged main into the branch while this round ran. The push replaced that merge with a rebase onto the same main, so the branch holds every commit of that merge.

dan-petty pushed a commit that referenced this pull request Nov 12, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.115.0](v0.114.1...v0.115.0)
(2026-11-12)


### Features

* **design:** add the design tokens and their build
([#4811](#4811))
([db4b19a](db4b19a))
* **roadmap:** find symbol definitions with tree-sitter
([#4820](#4820))
([3b3fddc](3b3fddc))


### Bug Fixes

* **ai:** the gateway group that answered decides the local label
([#4907](#4907))
([0da637f](0da637f))
* **ci:** replay a changed gate check in fail-to-pass
([#4898](#4898))
([59bfc57](59bfc57))
* **config:** read each config file as YAML 1.2
([#4858](#4858))
([c3130a3](c3130a3))
* **roadmap:** loosen the caps that turn a stage refusal into a loss
([#4869](#4869))
([4492fc3](4492fc3))
* **roadmap:** refine reads a dependency named by title
([#4877](#4877))
([2829f9c](2829f9c))
* **roadmap:** refine sends a judge refusal to an agent round
([#4874](#4874))
([e4fc6a9](e4fc6a9))
* **tests:** refuse test writes under the real home
([#4857](#4857))
([0f6ac1b](0f6ac1b))
* **tests:** the plain-Python helper test keeps PYTHONPATH
([#4914](#4914))
([99c109d](99c109d))


### Performance Improvements

* **ci:** direct pytest runs wait for a gate slot
([#4901](#4901))
([e80db62](e80db62))
* **roadmap:** status lane reads the snapshot, skips idle stops
([#4887](#4887))
([f285cf8](f285cf8))

---
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 bare off or on in YAML stops the settings load

1 participant