Improve error message for malformed hook command config#2042
Merged
Conversation
The previous error was an opaque "data did not match any variant of untagged enum CommandConfigToml" — users had no way to tell which of the three accepted forms (string, named table, pipeline list) they should use, or which value in their config was the problem. Replace the `#[serde(untagged)]` dispatch with a custom Visitor. Top-level type mismatches now list all three accepted forms inline with a pointer to `wt hook --help`; nested errors (non-string values inside a map) identify the specific offending value and point at it in the TOML span. Behavior for valid TOML is unchanged. Also add a Multiline String Literals subsection to CLAUDE.md's Code Quality section, covering the canonical style for multiline constants. Co-Authored-By: Claude <noreply@anthropic.com>
worktrunk-bot
approved these changes
Apr 10, 2026
Add a test for `command = [42]` so the integer-in-pipeline path exercises PipelineEntryVisitor::expecting (which only fires through serde's error machinery on type mismatch). Closes a codecov/patch gap on those lines. Move the message itself into a module-level EXPECTING_PIPELINE_ENTRY constant — the prior \-line continuation violated the new "Multiline String Literals" guidance in CLAUDE.md. Co-Authored-By: Claude <noreply@anthropic.com>
worktrunk-bot
approved these changes
Apr 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The previous error was an opaque "data did not match any variant of untagged enum CommandConfigToml" — users had no way to tell which of the three accepted forms (string, named table, pipeline list) they should use, or which value in their config was the problem.
What changed
Replace
#[serde(untagged)]dispatch inCommandConfig/PipelineEntrywith customVisitorimpls. Top-level type mismatches now list all three accepted forms inline with a pointer towt hook --help; nested errors (non-string values inside a map) identify the specific offending value and point at its TOML span. Behavior for valid TOML is unchanged.Before
After
Top-level mismatch (
post-merge = 42):Nested mismatch (
post-merge = [{ build = "cargo build", ignore_exit = true }]):CLAUDE.md
Also adds a "Multiline String Literals" subsection to Code Quality, documenting the canonical style (plain multiline literals, no
\-continuation, noconcat!()) and when to use raw strings.Testing
Three new inline-snapshot tests lock in the improved error messages (top-level wrong type, non-string in named table, non-string in pipeline map). Full suite (2962 tests + lints + doctests + doc build) passes.