Skip to content

Return structured resolver errors and keep Rich/Typer rendering in the CLI layer - #48

Merged
nicoloesch merged 4 commits into
mainfrom
22-structured-resolver-errors
Nov 19, 2026
Merged

nicoloesch merged 4 commits into
mainfrom
22-structured-resolver-errors

Conversation

@nicoloesch

@nicoloesch nicoloesch commented Oct 23, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Resolver and planner functions now raise structured issues instead of printing to a Rich console and raising typer.Exit. The CLI catches them, renders the same output as before, and exits with status 1. Headless callers such as plan_configure read the issues directly.

Changes

  • Add ConfigIssue, IssueCode, Severity and ConfigIssuesError in issues.py, exported from the package. ConfigIssuesError subclasses ConfigurationError.
  • Each issue has a stable code, message, severity, package/section/entry/schema context, an optional dotted field_path, related names and the pydantic error_type. A cross-field validator failure is an entry-level issue with field_path=None. Issues are built from sanitized errors, so rejected values do not leak.
  • Cover the four paths from the issue (missing required fields, invalid entry, test collision, unknown field) plus the test-only mismatch and an unverifiable collision check.
  • Remove the headless flag from the resolver helpers and resolve_fields. Nothing in the resolver prints or exits.
  • Move Rich rendering into cli_support.py (_exit_on_config_issues), used by _add_entry and PackageConfigBase.run_configure.
  • Make PackageConfigInvalidError a ConfigIssuesError, so both failure paths of plan_configure expose .issues. .errors() is kept. ConfigurationError moves to issues.py and is still importable from package_base.
  • Add issue_context and ConfigIssue.within, applied at the nested entry sites, resolve_fields and _add_entry. Issues from a nested entry get a dotted field_path and the package, section and entry of the outermost entry. The CLI shows a --set hint for dotted paths.
  • Drop the typer.Exit catch in plan_configure, which can no longer happen.
  • Update docs/integration.md and the affected tests, and add tests for each issue code.

Behaviour

  • CLI output and exit codes are unchanged, checked by running the same commands before and after and diffing the output.
  • Dynamic parts of the Rich output are now escaped, so text containing [ renders literally.
  • A collision check that cannot verify production safety now prints an error and exits 1 instead of a traceback.
  • headless= is no longer accepted by resolve_fields and the private resolver helpers.

Checklist

  • Applied exactly one label (feature)
  • Tests pass locally (pytest -q): 627 passed
  • Lint and type checks pass (ruff check ., ty check src/ tests/)

@nicoloesch nicoloesch added the feature New backwards-compatible functionality. MINOR: x.y+1.z label Oct 23, 2026
@nicoloesch
nicoloesch force-pushed the 22-structured-resolver-errors branch from a80c399 to 8012328 Compare October 27, 2026 03:27
@nicoloesch
nicoloesch marked this pull request as ready for review November 7, 2026 17:38
@nicoloesch nicoloesch linked an issue Nov 7, 2026 that may be closed by this pull request
1 task done
@nicoloesch
nicoloesch requested a review from gkennos November 8, 2026 14:43
Base automatically changed from 38-bump-ty-ruff to main November 16, 2026 04:43
@nicoloesch
nicoloesch force-pushed the 22-structured-resolver-errors branch from 8012328 to 4969ae8 Compare November 16, 2026 21:24
@nicoloesch
nicoloesch added this pull request to stack #59 November 16, 2026 22:05
Comment thread src/oa_configurator/resolver.py Resolved
@gkennos
gkennos self-requested a review November 18, 2026 07:26
@nicoloesch
nicoloesch merged commit d0b8faf into main Nov 19, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New backwards-compatible functionality. MINOR: x.y+1.z

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Return structured resolver errors and keep Rich/Typer rendering in the CLI layer

2 participants