Skip to content

Improvement: Error handling for malformed config files in check-hooks-installed.py and check_cargo_lints.py #69

Description

@sharanammahosur96

Description

Both pre-commit-action/check-hooks-installed.py and shared-lints/check_cargo_lints.py assume their input files are well-formed. If a config file is malformed, the scripts raise unhandled exceptions instead of a clean failure message.

Motivation

Why is this change needed?
What is the benefit to users, maintainers, or performance?

Contributors fixing their .pre-commit-config.yaml or Cargo.toml should get a message that tells them what's wrong with their file, not an internal traceback.
This also makes failures easier to triage from CI logs alone.

Proposed Solution

  • Wrap the YAML/TOML parsing calls in try/except
  • On parse failure, print a clear [FAIL] message (consistent with existing output style) identifying which file failed and why, then exit 1
  • Add/extend test coverage for malformed-input cases

(Optional) Briefly describe your idea for how this could be solved.
You can also link to any relevant code, design documents, or references.

Additional Context

(Optional) Add any screenshots, related issues, or architectural concerns.

Important

Make sure to link this issue with the PR for your improvement.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions