Skip to content

config: collect_config_issues raises on parseable-but-malformed YAML — 500 from /api/config/validate (contract says "never raises") #119

Closed

Description

@falbany

Problem

collect_config_issues documents itself as "never raises" (src/profiles/core/config/diagnostics.py:7), but line 45 calls collect_issues(raw) outside any try. Three verified crashes on content ruamel parses fine:

Draft Crash
configs: {a: {extends: [b]}} TypeError: cannot use 'CommentedSeq' as a dict key at validator.py:49 (extends not in configs)
Top-level scalar 42 TypeError: 'int' object is not iterable at validator.py:35 — enabled by read_yaml_text returning any YAML node despite its -> dict annotation (io/yaml_io.py:50-60)
Top-level YAML list AttributeError: 'CommentedSeq' object has no attribute 'get' at validator.py:39

Blast radius

  • POST /api/config/validate → 500 (routes/config.py:187-203).
  • POST /api/config/save: validate_issues runs before the force check (config.py:467-469), so even force-save cannot write such drafts — the user gets a 500 instead of a 400 issue list.

Suggested fix

  1. In read_yaml_text/read_yaml, type-narrow to Mapping — raise ValueError("configuration root must be a mapping") otherwise (or return {} and let diagnostics report it).
  2. In validator.collect_issues, guard isinstance(extends, str) and isinstance(raw, Mapping).
  3. Belt-and-braces: wrap the collect_issues call in collect_config_issues and convert any exception into an {"severity": "error", ...} issue.

Activity

  1. X6M-Work commented on Nov 6, 2026

    @X6M-Work
    Contributor

    Submitted a fix in PR #157 with test coverage for scalar roots, list roots, and non-string extends.

  2. added a commit that references this issue on Nov 7, 2026
    55f4ae5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions