Skip to content

fix(builtins): preserve typos errors with custom shells - #1398

Merged
jdx merged 2 commits into
jdx:mainfrom
zeitlinger:fix/typos-check-status
Sep 18, 2026
Merged

jdx merged 2 commits into
jdx:mainfrom
zeitlinger:fix/typos-check-status

Conversation

@zeitlinger

@zeitlinger zeitlinger commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

The typos builtin captures its diagnostic output in a shell variable before returning it. With a custom shell that does not enable errexit (for example, shell = "sh -c"), a failing typos invocation can otherwise be followed by the empty-output success path and incorrectly report success.

Preserve the command's status explicitly before the empty-output check. The default hk shell already enables errexit; this fix specifically protects custom shells that opt out of it.

Tests cover invalid native configuration, the builtin check/fix cases, and both default-errexit and custom sh -c shells.

AI-assisted — Tool: Codex; model: OpenAI/unavailable; version: unavailable.

Summary by CodeRabbit

  • Tests
    • Added coverage for the typos check and fix workflows.
    • Verified configuration exclusions and automatic correction of invalid files.
    • Confirmed error statuses and messages are preserved when configuration cannot be read or contains invalid TOML.
    • Tested behavior across supported shell execution modes, including diff output and prevention of unintended fallback actions.

Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
@coderabbitai

coderabbitai Bot commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited), Organization UI (inherited)

Review profile: CHILL

Plan: Advanced

Run ID: 8c590fd4-c0b4-42c4-a6f2-7735e54e3b83

📥 Commits

Reviewing files that changed from the base of the PR and between 894f0e2 and 6a513bd.

⛔ Files ignored due to path filters (1)
  • pkl/builtins/typos.pkl is excluded by !**/*.pkl
📒 Files selected for processing (1)
  • test/typos.bats

Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review.


📝 Walkthrough

Walkthrough

The PR adds BATS coverage for the typos builtin. The tests cover successful checks and fixes, tool exit-code and stderr propagation, diff-based fixes, and invalid TOML configuration.

Changes

Typos builtin test coverage

Layer / File(s) Summary
Test harness and successful typos runs
test/typos.bats
Adds setup for the typos builtin and verifies successful check and fix scenarios.
Failure propagation and diff-based fixes
test/typos.bats
Verifies exit code 78 and stderr propagation. It also verifies that hk fix applies the diff output and does not use the --write-changes fallback.
Invalid native configuration
test/typos.bats
Verifies that check and fix fail when typos.toml contains invalid TOML.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 6a513

The custom-shell regression cases are covered; no actionable merge risk remains.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: preserving errors from the typos builtin when custom shells are used.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI

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

Comment @coderabbitai help to get the list of available commands.

@zeitlinger
zeitlinger marked this pull request as ready for review September 17, 2026 14:34
@greptile-apps

greptile-apps Bot commented Sep 17, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

The PR appears safe to merge; the previously reported loss of captured diffs is resolved and no new actionable issue remains.

Summary

This PR fixes the typos builtin’s behavior under custom shells that do not enable errexit.

  • Captures the typos --diff exit status without discarding stdout.
  • Preserves silent operational failure statuses while forwarding captured typo diffs.
  • Adds builtin and Bats coverage for invalid configuration, check/fix behavior, default shells, and custom sh -c shells.

Reviews (2) · Last reviewed commit: "fix(builtins): preserve typos diffs with..."

Comment thread pkl/builtins/typos.pkl Resolved
Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
@jdx
jdx merged commit 4e07420 into jdx:main Sep 18, 2026
25 checks passed
@jdx jdx mentioned this pull request Sep 18, 2026
jdx added a commit that referenced this pull request Sep 23, 2026
### 🚀 Features

- **(builtins)** add kube-linter for plain Kubernetes manifests by
[@zeitlinger](https://github.com/zeitlinger) in
[#1394](#1394)
- **(builtins)** add fix for editorconfig-checker by
[@lucacome](https://github.com/lucacome) in
[#1397](#1397)
- **(builtins)** add dotnet formatting for C# and Visual Basic by
[@zeitlinger](https://github.com/zeitlinger) in
[#1393](#1393)
- **(pkl)** support glob imports in hk configuration by
[@jdx](https://github.com/jdx) in
[#1423](#1423)

### 🐛 Bug Fixes

- **(builtins)** preserve typos errors with custom shells by
[@zeitlinger](https://github.com/zeitlinger) in
[#1398](#1398)
- **(config)** pick up pkl import changes that hk's config cache used to
miss by [@jdx](https://github.com/jdx) in
[#1422](#1422)
- **(pre-push)** warn instead of crashing on malformed lines from stdin
by [@connormharris](https://github.com/connormharris) in
[#1352](#1352)

### 🧪 Testing

- **(bats)** preinstall builtin tool stubs to stop spurious symlink
failures by [@jdx](https://github.com/jdx) in
[#1396](#1396)

### 🛡️ Security

- add entire trail runners by [@jdx](https://github.com/jdx) in
[#1399](#1399)

### 🔍 Other Changes

- **(ci)** comment on a discussion when the PR implementing it merges by
[@jdx](https://github.com/jdx) in
[#1413](#1413)
- re-pin aube-lock reusable workflow to current renovate-config main by
[@jdx](https://github.com/jdx) in
[#1388](#1388)
- regenerate mise.lock on renovate branches so tool bumps stop failing
every job by [@jdx](https://github.com/jdx) in
[#1389](#1389)
- fix macOS bats attempt-1 timeouts and publish builtin test timings by
[@jdx](https://github.com/jdx) in
[#1395](#1395)
- remove entire and codex agent hooks by [@jdx](https://github.com/jdx)
in
[b23b605](b23b605)
- re-pin renovate-config reusable workflows to current main by
[@jdx](https://github.com/jdx) in
[#1408](#1408)
- stop compiling cargo-edit and rebuilding hk in every CI job by
[@jdx](https://github.com/jdx) in
[#1410](#1410)
- re-pin renovate-config reusable workflows to current main by
[@jdx](https://github.com/jdx) in
[24fe99e](24fe99e)

### 📦️ Dependency Updates

- update anthropics/claude-code-action action to v1.0.217 by
[@renovate[bot]](https://github.com/renovate[bot]) in
[#1382](#1382)
- update dependency github:jdx/tak to v0.0.10 by
[@renovate[bot]](https://github.com/renovate[bot]) in
[#1384](#1384)
- update rust crate dirs to v7 by
[@renovate[bot]](https://github.com/renovate[bot]) in
[#1386](#1386)
- update dependency @modelcontextprotocol/ext-apps to v2 by
[@renovate[bot]](https://github.com/renovate[bot]) in
[#1387](#1387)
- update anthropics/claude-code-action action to v1.0.219 by
[@renovate[bot]](https://github.com/renovate[bot]) in
[#1391](#1391)
- update dependency vitest to v5 by
[@renovate[bot]](https://github.com/renovate[bot]) in
[#1385](#1385)
- update dependency aube to latest by
[@renovate[bot]](https://github.com/renovate[bot]) in
[#1383](#1383)
- update rust crate xx to v2.6.2 by
[@renovate[bot]](https://github.com/renovate[bot]) in
[#1406](#1406)
- update rust crate pklr to v2.0.5 by
[@renovate[bot]](https://github.com/renovate[bot]) in
[#1407](#1407)
- bump mr-boxington to 1.14.0 and drop the mbx fallback docs by
[@jdx](https://github.com/jdx) in
[#1409](#1409)
- update zizmorcore/zizmor-action action to v0.6.4 by
[@renovate[bot]](https://github.com/renovate[bot]) in
[#1419](#1419)
- update anthropics/claude-code-action action to v1.0.225 by
[@renovate[bot]](https://github.com/renovate[bot]) in
[#1414](#1414)
- update anthropics/claude-code-action action to v1.0.226 by
[@renovate[bot]](https://github.com/renovate[bot]) in
[#1426](#1426)

### New Contributors

- @connormharris made their first contribution in
[#1352](#1352)
- @zeitlinger made their first contribution in
[#1398](#1398)
- @lucacome made their first contribution in
[#1397](#1397)

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Low Risk**
> Version and documentation pin updates only; functional changes are
already merged and summarized in the changelog.
> 
> **Overview**
> **Cuts release v2.1.0** by bumping the crate and CLI metadata from
`2.0.1` to `2.1.0` (`Cargo.toml`, `Cargo.lock`, `hk.usage.kdl`,
`docs/cli/commands.json`) and aligning every docs/example
`package://…/hk@…` pin to the new release URL.
> 
> Adds a **2.1.0 `CHANGELOG.md` section** (dated 2026-09-23) that
records what ships in this tag: new builtins (kube-linter,
editorconfig-checker fix, dotnet format), Pkl glob imports, config-cache
and pre-push robustness fixes, typos/custom-shell behavior, trail
runners, CI/test tweaks, and dependency bumps. The **2.0.1** entry date
is corrected to 2026-09-15.
> 
> No application logic changes appear in this diff—only release
bookkeeping and documentation version strings.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
f80e48e. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

Co-authored-by: mise-en-dev <123107610+mise-en-dev@users.noreply.github.com>
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.

2 participants