Skip to content

Refactor app validation errors: result-based parsing, structured error data#7126

Open
ryancbahan wants to merge 3 commits intomainfrom
ryan/structured-app-errors
Open

Refactor app validation errors: result-based parsing, structured error data#7126
ryancbahan wants to merge 3 commits intomainfrom
ryan/structured-app-errors

Conversation

@ryancbahan
Copy link
Copy Markdown
Contributor

@ryancbahan ryancbahan commented Mar 30, 2026

What

Refactor app validation error handling from throw/catch with styled OutputMessage to result-based parsing with a plain ConfigurationError data interface.

Why

Prep for app config validate --json (see #7066, #7090, #7106). The original stack added structured error data alongside rendered messages, creating dual-track serialization in the loader. This PR takes the opposite approach: make errors pure data, let callers render. This gives callers more flexibility and removes the job of rendering/formatting from the data flow.

How

  • ConfigurationError is now a plain interface ({file, message, path?, code?}), not a class extending AbortError
  • parseConfigurationObject, parseConfigurationObjectAgainstSpecification, parseConfigurationFile return {data} | {errors: ConfigurationError[]} instead of throwing
  • AppErrors stores ConfigurationError[] with addError, addErrors, getErrors(file?), isEmpty
  • formatConfigurationError is the single plain-text formatting function
  • Styled output (outputContent/outputToken) applied only at display boundaries: app-context.ts (AbortError), validate.ts (renderError), loader.ts (reloadApp)
  • parseStructuredErrors in error-parsing.ts converts Zod issues to ParsedIssue[] with union-variant scoring

No user-facing behavior changes. CLI output preserves styling. Multi-error-per-file now preserved (previously silently overwritten by dictionary key).

@ryancbahan ryancbahan requested a review from a team as a code owner March 30, 2026 18:26
@github-actions
Copy link
Copy Markdown
Contributor

We detected some changes at packages/*/src and there are no updates in the .changeset.
If the changes are user-facing, run pnpm changeset add to track your changes and include them in the next release CHANGELOG.

Caution

DO NOT create changesets for features which you do not wish to be included in the public changelog of the next CLI release.

Copy link
Copy Markdown
Contributor Author

ryancbahan commented Mar 30, 2026

ryancbahan and others added 3 commits March 30, 2026 15:48
…r data

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…r data

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…r data

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@ryancbahan ryancbahan force-pushed the ryan/structured-app-errors branch from 768157b to 3249375 Compare March 30, 2026 21:48
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