Skip to content

bug: validate nested configuration shape before merge and provenance traversal #359

Description

@codeforester

Problem

The batteries-included loader handles malformed configuration inconsistently: recursive YAML mappings cause an internal RecursionError, while non-string nested mapping keys bypass the top-level string-key validation. Validation depends on the data's position and existing merge layers.

Verified evidence

Reviewed on 2026-09-17 at 2d67cd24e8d704386f2be7d3a41addc06fb81e17 (local checkout matched GitHub main). Reproduced in isolated macOS environments with Python 3.14.6. Framework default probe environment: Click 8.5.0 and Typer 0.27.2. Demo probes used released base-cli 0.4.3 unless noted.

Using the public BatteriesIncludedConfigLoader: a recursive mapping alias raises RecursionError; a mapping with a numeric key under nested is accepted unchanged; the same numeric key at top level raises ConfigurationError. The recursive file through run_app exits 1 with Unexpected internal error, rather than a path-specific configuration usage error. _leaf_provenance() traverses mappings without a cycle guard, while _merge_mapping() validates keys only on the levels it directly visits.

Sources:

Acceptance criteria

  • Validate the mapping graph consistently before merging or collecting provenance, with explicit cycle/depth handling and string-key policy.
  • Report unsupported shapes as actionable ConfigurationError/exit 2 with the selected source path; avoid an uncontrolled RecursionError.
  • Accept harmless shared aliases without conflating them with cycles, and keep valid nested merge/provenance behavior.
  • Test first insertion and subsequent overlay of the same invalid shape, plus native/attached human and JSON error paths.

Related work

Follow-up to closed #263. This concerns malformed configuration and traversal consistency; it does not impose a schema on ordinary consumer values.

Project fields

  • Status: Backlog
  • Priority: P2
  • Area: Python
  • Initiative: v1.0 Readiness
  • Size: M
  • Assignee: @codeforester
  • Milestone: v1.0.0
  • Target date: unscheduled

Activity

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

Metadata

Metadata

Assignees

Labels

bugSomething is not working

Type

Projects

  • Status
    In Progress

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions