Skip to content

♻️ Surface settings errors with typed codes and paths#290

Merged
Gudsfile merged 3 commits into
mainfrom
169-cli-boundaries
Jun 20, 2026
Merged

♻️ Surface settings errors with typed codes and paths#290
Gudsfile merged 3 commits into
mainfrom
169-cli-boundaries

Conversation

@Gudsfile

@Gudsfile Gudsfile commented Jun 20, 2026

Copy link
Copy Markdown
Owner

Summary

Refs #169

  • Settings errors now carry a machine-readable code and the path of the affected setting, so there is a reliable way to inspect what failed without parsing error strings.
  • The CLI uses these fields to build user-facing messages, replacing brittle string matching on error text.
  • Pydantic validation failures are rendered using the structured errors API rather than a custom text parser.
  • Migration errors (invalid JSON root structure) now also carry the file path — previously lost before reaching the CLI renderer.

Test plan

  • Run jukebox-admin settings set <unsupported.path> value and verify the error message names the path.
  • Set a setting to an invalid JSON value and verify the message distinguishes between a parse failure and a wrong type.
  • Trigger a Pydantic validation failure (e.g. set a port to a string) and verify the field name and constraint appear in the output.
  • Run with --verbose and verify full details are still visible.
  • Write a settings file whose JSON root is an array (e.g. [1,2,3]) and verify the error message includes the file path.

@Gudsfile Gudsfile force-pushed the 169-cli-boundaries-a branch 2 times, most recently from 5295dfd to 74aced7 Compare June 20, 2026 20:54
Base automatically changed from 169-cli-boundaries-a to main June 20, 2026 20:54
@Gudsfile Gudsfile force-pushed the 169-cli-boundaries branch 2 times, most recently from 961916a to 911cd75 Compare June 20, 2026 21:54
Gudsfile added 3 commits June 21, 2026 01:03
Add ErrorCode (StrEnum) and optional path to InvalidSettingsError so
callers can inspect failure kind and affected path without message parsing.
Update all raise sites across settings, migration, and adapter layers.
Replace message.startswith() sub-classification in _render_invalid_settings_error
with a match on err.code, and path extraction with err.path.
Replace text parsing in _extract_compact_detail with ValidationError.errors()
when the error's __cause__ is a ValidationError. Non-validation failures
(ValueError, patch format errors) retain the text-fallback path.
@Gudsfile Gudsfile force-pushed the 169-cli-boundaries branch from 911cd75 to 1969ede Compare June 20, 2026 23:03
@Gudsfile

Gudsfile commented Jun 20, 2026

Copy link
Copy Markdown
Owner Author

uv run jukebox-admin settings set jukebox.reader.pn532.spi.cs.toto 12

Unsupported settings path: 'jukebox.reader.pn532.spi.cs.toto'. Use `jukebox-admin settings show --effective --json` to inspect supported editable paths.

extra ,

Malformed settings file at '/Users/username/.config/jukebox/settings.json'. Fix the JSON syntax and try again.

"jukebox": { "reader": { "type": "toto" } }

Persisted settings are invalid at '/Users/username/.config/jukebox/settings.json': jukebox.reader.type: Input should be 'dryrun' or 'pn532'

uv run jukebox-admin settings set admin.api.port toto

Settings update rejected: admin.api.port: Input should be a valid integer, unable to parse string as an integer

"admin": { "api": { "port": -1 } }

Persisted settings are invalid at '/Users/username/.config/jukebox/settings.json': admin.api.port: Input should be a valid integer, unable to parse string as an integer

"admin": { "api": { "port": -1 } } + --verbose

Persisted settings are invalid at '/Users/username/.config/jukebox/settings.json': admin.api.port: Input should be greater than or equal to 1

Details: Invalid settings file at '/Users/username/.config/jukebox/settings.json': 1 validation error for PersistedAppSettings
admin.api.port
  Input should be greater than or equal to 1 [type=greater_than_equal, input_value=-12, input_type=int]
    For further information visit https://errors.pydantic.dev/2.13/v/greater_than_equal

@Gudsfile Gudsfile marked this pull request as ready for review June 20, 2026 23:40
@Gudsfile Gudsfile self-assigned this Jun 20, 2026
@Gudsfile Gudsfile changed the title Surface settings errors with typed codes and paths ♻️ Surface settings errors with typed codes and paths Jun 20, 2026
@Gudsfile Gudsfile merged commit 7ff88a0 into main Jun 20, 2026
5 checks passed
@Gudsfile Gudsfile deleted the 169-cli-boundaries branch June 20, 2026 23:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant