Skip to content

Always show full config parse errors with full details in output#2149

Merged
mre merged 1 commit into
masterfrom
fix-toml-config-error-output
Apr 17, 2026
Merged

Always show full config parse errors with full details in output#2149
mre merged 1 commit into
masterfrom
fix-toml-config-error-output

Conversation

@mre

@mre mre commented Apr 17, 2026

Copy link
Copy Markdown
Member

The root cause is that the error was formatted with {} (Display), which for anyhow only shows the outermost message in the error chain.

Since d5d22bc restructured the error handling to use e.context(msg), which wraps the TOML details under the context message, the Display format only shows the context message and loses the TOML parse error details (line number, column, offending value, etc.).

Changing {} to {:?} uses anyhow's Debug format, which prints the full error chain:

Fixes #2146

The root cause is that the error was formatted with `{}` (Display),
which for `anyhow` only shows the outermost message in the error chain.
Since
d5d22bc
restructured the error handling to use `e.context(msg)`, which wraps the
TOML details *under* the context message, the Display format only shows
the context message and loses the TOML parse error details (line number,
column, offending value, etc.).

Changing `{}` to `{:?}` uses `anyhow`'s Debug format, which prints the
full error chain:

Fixes #2146
@mre mre requested a review from katrinafyi April 17, 2026 10:17

@katrinafyi katrinafyi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a quick and easy fix, awesome!

I was curious and this is what the error looks like for package.json after this change.

 [ERROR] Error while loading config: Cannot load configuration file: package.json

Caused by:
    0: Failed to parse lychee config from package.json
    1: invalid type: string "a", expected a nonzero usize at line 3 column 18
See: https://github.com/lycheeverse/lychee/blob/lychee-v0.23.0/lychee.example.toml

@mre

mre commented Apr 17, 2026

Copy link
Copy Markdown
Member Author

That looks really good!

@mre mre merged commit 4b588d4 into master Apr 17, 2026
8 checks passed
@mre mre deleted the fix-toml-config-error-output branch April 17, 2026 11:40
@mre

mre commented Apr 17, 2026

Copy link
Copy Markdown
Member Author

Thanks for the review and the check. 😀

@mre mre mentioned this pull request Apr 17, 2026
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.

TOML error messages regressed

2 participants