Skip to content

Comments

fix: treat check_list_files stderr as informational, not an error#425

Merged
jdx merged 2 commits intomainfrom
fix/check-list-files-stderr-handling
Nov 19, 2025
Merged

fix: treat check_list_files stderr as informational, not an error#425
jdx merged 2 commits intomainfrom
fix/check-list-files-stderr-handling

Conversation

@jdx
Copy link
Owner

@jdx jdx commented Nov 18, 2025

Summary

Change check_list_files to only read files from stdout and treat stderr as informational output (warnings, debug info, etc.). The only error condition is when the command exits non-zero with no files in stdout, which indicates a tool failure rather than "files need fixing".

Problem

Previously, check_list_files had overly strict error handling:

  • Exit 0 with stderr → treated as error
  • Exit non-zero with empty stdout + stderr → treated as error

This prevented tools from outputting warnings or debug information to stderr, and incorrectly flagged some legitimate scenarios as errors.

Solution

Updated error handling to be more permissive:

Exit Code Files in stdout Stderr Result
0 Empty Empty ✅ Success - no files need fixing
0 Empty Non-empty ✅ Success - stderr is just warnings
0 Has files Any ✅ Success with ⚠️ warning (misconfiguration)
Non-zero Empty Any Error - tool failed
Non-zero Has files Any ✅ Run fixer on those files

Key changes:

  • Files are only read from stdout (never stderr)
  • Stderr is logged as debug output for visibility
  • Exit 0 with files in stdout generates a warning (tool should exit non-zero when files need fixing)
  • The ONLY error case: non-zero exit with no files (indicates tool crashed/failed)

Changes

  • src/step.rs:

    • Removed error check for exit 0 + stderr
    • Added warning for exit 0 + files (misconfiguration)
    • Updated error handling for non-zero exit with no files
    • Regular check commands continue to work as before
  • test/check_list_files_empty_with_stderr.bats:

    • Updated test 1: Exit 0 + stderr is now success (was error)
    • Added test 5: Exit 0 + files shows warning

Test Plan

  • ✅ All tests pass with HK_LIBGIT2=0
  • ✅ All tests pass with HK_LIBGIT2=1
  • ✅ Related tests continue to pass: output_summary_check_first.bats, check_fix_suggestion.bats, stage_job_files.bats

🤖 Generated with Claude Code


Note

Make check_list_files read files only from stdout and treat stderr as informational, refine error handling (incl. diff fallback) and add warnings; update tests accordingly.

  • Core behavior – src/step.rs:
    • Treat stderr as informational for both check_list_files and check_diff; read files only from stdout.
    • When check_first fails:
      • check_diff: if no parseable files, keep all original files.
      • check_list_files: if files list is empty, treat as error only when the command failed; log stderr and return original error.
    • Add debug logging of check stderr; warn when check_list_files exits 0 but outputs files (possible misconfiguration).
  • Tests – test/check_list_files_empty_with_stderr.bats:
    • Update test to accept exit 0 + stderr as success and not run fixes.
    • Add tests for non-zero exit with no files (error) and for exit 0 returning files (warn, no fixes).

Written by Cursor Bugbot for commit 015a485. This will update automatically on new commits. Configure here.

jdx and others added 2 commits November 18, 2025 15:39
Change check_list_files to only treat non-zero exit with no files as an
error. Previously, stderr output was treated as an error even when the
command exited successfully, which was overly strict.

Problem:
- check_list_files with exit 0 + stderr was treated as an error
- This prevented tools from outputting warnings/info to stderr
- The only real error case is: non-zero exit with no files (tool failure)

Solution:
- When exit 0: stderr is logged as debug only (informational)
- When exit 0 with files in stdout: warn about misconfiguration
- When exit non-zero with no files: error (tool failed)
- When exit non-zero with files: run fixer on those files
- Regular check commands continue to work as before

Changes:
- src/step.rs: Removed stderr error checks, added warning for exit 0 + files
- test/check_list_files_empty_with_stderr.bats: Updated all test cases and
  added new test for the misconfiguration warning

All tests pass with both HK_LIBGIT2=0 and HK_LIBGIT2=1.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@jdx jdx merged commit 3a44ff9 into main Nov 19, 2025
19 of 25 checks passed
@jdx jdx deleted the fix/check-list-files-stderr-handling branch November 19, 2025 17:09
@jdx jdx mentioned this pull request Nov 19, 2025
jdx added a commit that referenced this pull request Nov 19, 2025
## [1.21.1](https://github.com/jdx/hk/compare/v1.21.0..v1.21.1) -
2025-11-19

### 🐛 Bug Fixes

- **(ruff)** Make `ruff` respect user config `exclude` by
[@thejcannon](https://github.com/thejcannon) in
[#421](#421)
- **(ruff_format)** Pass `--force-exclude` to `ruff format` (as well) by
[@thejcannon](https://github.com/thejcannon) in
[#428](#428)
- Fix --check docstring by [@thejcannon](https://github.com/thejcannon)
in [#423](#423)
- Configuration Read Support YML File Extension by
[@hcoona](https://github.com/hcoona) in
[#427](#427)
- treat check_list_files stderr as informational, not an error by
[@jdx](https://github.com/jdx) in
[#425](#425)

### 🚜 Refactor

- Enable `trailing-whitespace` in this repo by
[@thejcannon](https://github.com/thejcannon) in
[#429](#429)

### 📚 Documentation

- Don't suggest configuring hk in config env by
[@thejcannon](https://github.com/thejcannon) in
[#424](#424)

### New Contributors

- @thejcannon made their first contribution in
[#428](#428)
- @hcoona made their first contribution in
[#427](#427)

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> Bump to 1.21.1 with updated docs/templates, corrected --check help
text, and minor dependency refresh.
> 
> - **Release/versioning**:
> - Bump crate to `1.21.1` in `Cargo.toml`, `Cargo.lock`,
`hk.usage.kdl`, and docs (`docs/cli/index.md`,
`docs/cli/commands.json`).
> - Update all `pkl` package URLs and examples to `v1.21.1` (init
template in `src/cli/init.rs`, docs, examples).
>   - Add `CHANGELOG.md` entry for `1.21.1`.
> - **CLI/help text**:
> - Fix `--check` help to “Run check command instead of fix command”
across CLI specs and docs (`docs/cli/*`, `hk.usage.kdl`,
`docs/cli/commands.json`).
> - **Code/messages**:
>   - Refresh Pkl error example version in `src/config.rs`.
> - **Dependencies**:
> - Update `clap`/`clap_builder` to `4.5.52` and `unit-prefix` to
`0.5.2` in `Cargo.lock`.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
3ed921a. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

Co-authored-by: mise-en-dev <[email protected]>
tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request Nov 21, 2025
This MR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [hk](https://github.com/jdx/hk) | minor | `1.20.0` -> `1.22.0` |

MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot).

**Proposed changes to behavior should be submitted there as MRs.**

---

### Release Notes

<details>
<summary>jdx/hk (hk)</summary>

### [`v1.22.0`](https://github.com/jdx/hk/blob/HEAD/CHANGELOG.md#1220---2025-11-19)

[Compare Source](jdx/hk@v1.21.1...v1.22.0)

##### 🚀 Features

- Add `stdin` to step config by [@&#8203;thejcannon](https://github.com/thejcannon) in [#&#8203;435](jdx/hk#435)

##### 🐛 Bug Fixes

- save patch backup files when using git as stash method by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;434](jdx/hk#434)

##### 📚 Documentation

- Clarify `stash` default (behavior) by [@&#8203;thejcannon](https://github.com/thejcannon) in [#&#8203;431](jdx/hk#431)
- Clarify hook fix default by [@&#8203;thejcannon](https://github.com/thejcannon) in [#&#8203;433](jdx/hk#433)

### [`v1.21.1`](https://github.com/jdx/hk/blob/HEAD/CHANGELOG.md#1211---2025-11-19)

[Compare Source](jdx/hk@v1.21.0...v1.21.1)

##### 🐛 Bug Fixes

- **(ruff)** Make `ruff` respect user config `exclude` by [@&#8203;thejcannon](https://github.com/thejcannon) in [#&#8203;421](jdx/hk#421)
- **(ruff\_format)** Pass `--force-exclude` to `ruff format` (as well) by [@&#8203;thejcannon](https://github.com/thejcannon) in [#&#8203;428](jdx/hk#428)
- Fix --check docstring by [@&#8203;thejcannon](https://github.com/thejcannon) in [#&#8203;423](jdx/hk#423)
- Configuration Read Support YML File Extension by [@&#8203;hcoona](https://github.com/hcoona) in [#&#8203;427](jdx/hk#427)
- treat check\_list\_files stderr as informational, not an error by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;425](jdx/hk#425)
- remove trailing whitespace in ruff\_format.pkl by [@&#8203;jdx](https://github.com/jdx) in [9f4abdc](jdx/hk@9f4abdc)

##### 🚜 Refactor

- Enable `trailing-whitespace` in this repo by [@&#8203;thejcannon](https://github.com/thejcannon) in [#&#8203;429](jdx/hk#429)

##### 📚 Documentation

- Don't suggest configuring hk in config env by [@&#8203;thejcannon](https://github.com/thejcannon) in [#&#8203;424](jdx/hk#424)

##### New Contributors

- [@&#8203;thejcannon](https://github.com/thejcannon) made their first contribution in [#&#8203;428](jdx/hk#428)
- [@&#8203;hcoona](https://github.com/hcoona) made their first contribution in [#&#8203;427](jdx/hk#427)

### [`v1.21.0`](https://github.com/jdx/hk/blob/HEAD/CHANGELOG.md#1210---2025-11-15)

[Compare Source](jdx/hk@v1.20.0...v1.21.0)

##### 🚀 Features

- **(dprint)** new builtin by [@&#8203;scop](https://github.com/scop) in [#&#8203;402](jdx/hk#402)
- **(mypy,ruff,ruff\_format)** associate with .pyi by [@&#8203;scop](https://github.com/scop) in [#&#8203;404](jdx/hk#404)
- **(prettier)** support Vue files by [@&#8203;minusfive](https://github.com/minusfive) in [#&#8203;388](jdx/hk#388)
- **(terraform,tofu)** include .tftest.hcl in glob by [@&#8203;scop](https://github.com/scop) in [#&#8203;397](jdx/hk#397)
- **(tflint)** add fix command by [@&#8203;scop](https://github.com/scop) in [#&#8203;401](jdx/hk#401)
- **(typos)** new builtin by [@&#8203;scop](https://github.com/scop) in [#&#8203;400](jdx/hk#400)
- use recursive glob patterns in all builtins by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;383](jdx/hk#383)
- shfmt improvements by [@&#8203;scop](https://github.com/scop) in [#&#8203;410](jdx/hk#410)
- add content-based file type matching by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;416](jdx/hk#416)
- add clap-sort unit test and sort CLI flags alphabetically by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;419](jdx/hk#419)
- Add alternate config directory support with tests by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;407](jdx/hk#407)

##### 🐛 Bug Fixes

- **(golangci-lint)** check with --fix=false by [@&#8203;scop](https://github.com/scop) in [#&#8203;399](jdx/hk#399)
- **(shfmt)** don't pass -s by [@&#8203;scop](https://github.com/scop) in [#&#8203;398](jdx/hk#398)
- **(tf\_lint)** don't pass filenames by [@&#8203;scop](https://github.com/scop) in [#&#8203;396](jdx/hk#396)
- Import elixir builtins by [@&#8203;arthurcogo](https://github.com/arthurcogo) in [#&#8203;390](jdx/hk#390)
- Add warning for existing Git hooks path by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;409](jdx/hk#409)
- prevent untracked files from being staged with \<JOB\_FILES> by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;408](jdx/hk#408)

##### 📚 Documentation

- Add Elixir builtins to docs by [@&#8203;arthurcogo](https://github.com/arthurcogo) in [#&#8203;389](jdx/hk#389)
- glossary grammar fix by [@&#8203;scop](https://github.com/scop) in [#&#8203;395](jdx/hk#395)
- fix link to Pkl language docs by [@&#8203;scop](https://github.com/scop) in [#&#8203;394](jdx/hk#394)

##### 📦️ Dependency Updates

- update anthropics/claude-code-action digest to [`8a1c437`](jdx/hk@8a1c437) by [@&#8203;renovate\[bot\]](https://github.com/renovate\[bot]) in [#&#8203;391](jdx/hk#391)
- update jdx/mise-action digest to [`be3be22`](jdx/hk@be3be22) by [@&#8203;renovate\[bot\]](https://github.com/renovate\[bot]) in [#&#8203;392](jdx/hk#392)
- update github artifact actions (major) by [@&#8203;renovate\[bot\]](https://github.com/renovate\[bot]) in [#&#8203;393](jdx/hk#393)
- update rust crate infer to 0.19 by [@&#8203;renovate\[bot\]](https://github.com/renovate\[bot]) in [#&#8203;418](jdx/hk#418)
- update jdx/mise-action digest to [`9dc7d5d`](jdx/hk@9dc7d5d) by [@&#8203;renovate\[bot\]](https://github.com/renovate\[bot]) in [#&#8203;417](jdx/hk#417)

##### New Contributors

- [@&#8203;scop](https://github.com/scop) made their first contribution in [#&#8203;410](jdx/hk#410)
- [@&#8203;arthurcogo](https://github.com/arthurcogo) made their first contribution in [#&#8203;390](jdx/hk#390)
- [@&#8203;minusfive](https://github.com/minusfive) made their first contribution in [#&#8203;388](jdx/hk#388)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0MS4xNzMuMSIsInVwZGF0ZWRJblZlciI6IjQxLjE3My4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJSZW5vdmF0ZSBCb3QiXX0=-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant