Skip to content

Another round of improvements for config error messages#9746

Merged
etraut-openai merged 3 commits intomainfrom
etraut/config_errors
Jan 24, 2026
Merged

Another round of improvements for config error messages#9746
etraut-openai merged 3 commits intomainfrom
etraut/config_errors

Conversation

@etraut-openai
Copy link
Collaborator

@etraut-openai etraut-openai commented Jan 23, 2026

In a recent PR, I made some improvements to config error messages so errors didn't leave app server clients in a dead state. This is a follow-on PR to make these error messages more readable and actionable for both TUI and GUI users. For example, see #9668 where the user was understandably confused about the source of the problem and how to fix it.

The improved error message:

  1. Clearly identifies the config file where the error was found (which is more important now that we support layered configs)
  2. Provides a line and column number of the error
  3. Displays the line where the error occurred and underlines it

For example, if my config.toml includes the following:

[features]
collaboration_modes = "true"

Here's the current CLI error message:

Error loading config.toml: invalid type: string "true", expected a boolean in `features`

And here's the improved message:

Error loading config.toml:
/Users/etraut/.codex/config.toml:43:23: invalid type: string "true", expected a boolean
   |
43 | collaboration_modes = "true"
   |                       ^^^^^^

The bulk of the new logic is contained within a new module config_loader/diagnostics.rs that is responsible for calculating the text range for a given toml path (which is more involved than I would have expected).

In addition, this PR adds the file name and text range to the ConfigWarningNotification app server struct. This allows GUI clients to present the user with a better error message and an optional link to open the errant config file. This was a suggestion from @.bolinfest when he reviewed my previous PR.

I recently made some improvements to config error messages, but there's still room for improvement. For example, see #9668 where the user was understandably confused about the source of the problem and how to fix it.

The improved error message:
1. Clearly identifies the config file where the error was found (which is more important now that we support layered configs)
2. Provides a line and column number of the error
3. Displays the line where the error occurred and underlines it

For example, here's the current CLI error message:
```
Error loading config.toml: unknown variant `xxhigh`, expected one of `none`, `minimal`, `low`, `medium`, `high`, `xhigh`
in `model_reasoning_effort`
```

And here's the improved message:
```
Error loading config.toml:
/Users/etraut/.codex/config.toml:2:26: unknown variant `xxhigh`, expected one of `none`, `minimal`, `low`, `medium`, `high`, `xhigh`
  |
2 | model_reasoning_effort = "xxhigh"
  |                          ^^^^^^^^
```

In addition, this PR adds the file name and text range to the ConfigWarningNotification app server struct. This will allow GUI clients to present the user with a better error message. (This was a suggestion from @.bolinfest when he reviewed my previous PR.)
@etraut-openai
Copy link
Collaborator Author

@codex review

@chatgpt-codex-connector
Copy link
Contributor

Codex Review: Didn't find any major issues. Bravo.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link
Collaborator

@bolinfest bolinfest left a comment

Choose a reason for hiding this comment

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

Very nice and thoughtful change!

@etraut-openai etraut-openai merged commit 713ae22 into main Jan 24, 2026
32 checks passed
@etraut-openai etraut-openai deleted the etraut/config_errors branch January 24, 2026 04:11
@github-actions github-actions bot locked and limited conversation to collaborators Jan 24, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants