Skip to content

fix: print errors without a traceback from the pip and npm cpp-linter commands - #587

Merged
2bndy5 merged 1 commit into
mainfrom
claude/project-thread-kbgobw
Nov 17, 2026
Merged

2bndy5 merged 1 commit into
mainfrom
claude/project-thread-kbgobw

Conversation

@shenxianpeng

@shenxianpeng shenxianpeng commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

Found while testing v2.0.0-rc.26 (PyPI 2.0.0rc25, npm 2.0.0-rc.24) end to end.

The cpp-linter executable prints an error as Error: ... and exits with 1. The cpp-linter commands installed by pip and npm show a Python traceback or a Node.js stack trace instead, for every error, including the expected exit of the new --strict:

$ cpp-linter --strict        # pip, 2.0.0rc25
Traceback (most recent call last):
  File ".../bin/cpp-linter", line 6, in <module>
    sys.exit(main())
             ~~~~^^
OSError: Some checks did not pass
$ npx @cpp-linter/cpp-linter@2.0.0-rc.24 --strict
.../cli.js:6
cppLinter.main(process.argv);
          ^
Error: Some checks did not pass
    at Object.<anonymous> (.../cli.js:6:11)
    at Module._compile (node:internal/modules/cjs/loader:1781:14)
    ... 6 more lines of the stack ...
    at node:internal/main/run_main_module:36:49 {
  code: 'GenericFailure'
}

cpp-linter-action v3 runs the pip package, so its logs show the same traceback when a run stops on an error. Two examples from today's test runs: version: '' on macos-latest (no clang-tidy on PATH) and an empty GITHUB_TOKEN (401).

Changes

  • Python: a new cpp_linter.cli() function is the [project.scripts] entry point. On an error it prints Error: {e:?} (the same text as the executable, including the cause chain) and raises SystemExit(1). cpp_linter.main() is unchanged and still raises OSError, so scripts that call it see no difference.
  • Node.js: cli.js catches the error, prints Error: <message> and sets process.exitCode = 1. main() still throws.
  • The --strict help now says that the cpp-linter command prints the error and the bindings' main() raises it.

Tests

With a wheel built from this branch (maturin, CPython 3.13, RUST_BACKTRACE unset), in a test repo with staged files that fail some checks:

Command Before After
cpp-linter --strict traceback, exit 1 Error: Some checks did not pass, exit 1 (same as the executable)
cpp-linter --style=Nope traceback, exit 1 Error: clang-format failed on all 2 file(s) it ran on; ..., exit 1
cpp-linter --bogus usage, exit 2 unchanged
cpp-linter (no error) exit 0 unchanged
python -c "cpp_linter.main([... '--strict'])" OSError unchanged

The new cli.js was run with the published 2.0.0-rc.24 index.js: --strict prints Error: Some checks did not pass and exits 1; a normal run exits 0; --bogus exits 2.

cargo fmt --check, cargo clippy -p cpp-linter-py --all-targets -- -D warnings and cspell are clean.

@coderabbitai

coderabbitai Bot commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 46 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI (base), Organization UI (inherited)
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 46a4557e-cb69-4ddb-9ae9-ffa36ef62a33
Commits

Reviewing files that changed from the base of the PR and between 4ec7603 and 7c2298b.

Files ignored due to path filters: 1

  • Cargo.lock is excluded by !**/*.lock
Files selected for processing: 6

  • bindings/node/cli.js
  • bindings/python/Cargo.toml
  • bindings/python/src/lib.rs
  • cpp-linter/src/cli/mod.rs
  • cpp_linter.pyi
  • pyproject.toml
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@shenxianpeng shenxianpeng added the bug Something isn't working label Nov 17, 2026 — with Claude
@shenxianpeng shenxianpeng self-assigned this Nov 17, 2026
@shenxianpeng
shenxianpeng requested a review from 2bndy5 November 17, 2026 07:13
@codecov

codecov Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.63%. Comparing base (4ec7603) to head (7c2298b).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #587   +/-   ##
=======================================
  Coverage   99.63%   99.63%           
=======================================
  Files          29       29           
  Lines        8329     8329           
=======================================
  Hits         8299     8299           
  Misses         30       30           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@2bndy5
2bndy5 merged commit 191f727 into main Nov 17, 2026
108 checks passed
@2bndy5
2bndy5 deleted the claude/project-thread-kbgobw branch November 17, 2026 08:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants