+
Skip to content

feat: better error messages for invalid inputs #956

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 19, 2025
Merged

Conversation

woodruffw
Copy link
Member

The error in #952 now looks like this:

ERROR collect_inputs: github_actions_models::common: msg="repo action must have `@<ref>` in reusable workflow"
fatal: no audit was performed
failed to load input as Workflow

Caused by:
    0: failed to load workflow from file://tmp.yml
    1: couldn't turn input into a an appropriate model
    2: this suggests a bug in zizmor; please report it!
    3: jobs: data did not match any variant of untagged enum Job at line 23 column 3

Closes #952.

Closes #952.

Signed-off-by: William Woodruff <william@yossarian.net>
@woodruffw woodruffw self-assigned this Jun 19, 2025
@woodruffw woodruffw added the enhancement New feature or request label Jun 19, 2025
Signed-off-by: William Woodruff <william@yossarian.net>
Comment on lines +340 to +352
/// Wraps a `de::Error::custom` call to log the same error as
/// a `tracing::error!` event.
///
/// This is useful when doing custom deserialization within untagged
/// enum variants, since serde loses track of the original error.
pub(crate) fn custom_error<'de, D>(msg: impl Display) -> D::Error
where
D: Deserializer<'de>,
{
let msg = msg.to_string();
tracing::error!(msg);
de::Error::custom(msg)
}
Copy link
Member Author

Choose a reason for hiding this comment

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

NB: This is a pretty nasty hack -- I'd really prefer not to plumb tracing events down to this level, but serde swallows the Error::custom message itself when parsing untagged enum variants. So this is probably the shortest/simplest path towards surfacing this for debugging/diagnostics purposes.

@woodruffw woodruffw merged commit 64f9be5 into main Jun 19, 2025
8 checks passed
@woodruffw woodruffw deleted the ww/better-errors branch June 19, 2025 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unclear error message when a workflow fails to parse
1 participant
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载