feat(hooks): PostToolUse に UTF-8 整合性チェック (Layer 0) を追加 - #52
Conversation
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 47 minutes and 37 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughドキュメント(docs/todo.md)の運用ルールを更新し、スナップショット形式の慣例を廃止、完了タスクの削除ルールを明記しました。また、PostToolUse フックに UTF-8 整合性チェック機能を新たに追加し、テストケースを含めて実装しました。 Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@docs/todo.md`:
- Around line 35-39: Update the TODO status to reflect that the build step is
already complete: change the "ビルド+デプロイ待ち" entry to separate "ビルド: 完了" and "デプロイ:
未完了" (or mark only deploy as pending) and ensure the checklist still shows the
implemented items (`check_utf8_integrity()`, adding call in `main()`, and the
five tests) as checked so the current state accurately shows build succeeded but
deploy remains.
In `@src/hooks-post-tool-linter/src/main.rs`:
- Around line 389-397: The current UTF-8 integrity check sets
ViolationLocation.symbol to the entire line (line.trim().to_string()) when
line.contains('\u{FFFD}'), which leaks large or sensitive content; change it to
return only the detected token instead. In the block handling
line.contains('\u{FFFD}'), set ViolationLocation.symbol to the matched character
(e.g., the single U+FFFD replacement char found via line.chars().find(|c| *c ==
'\u{FFFD}').unwrap().to_string() or a constant "�".to_string()) rather than the
whole trimmed line; keep file and line_idx as-is so only the symbol field is
minimized. Ensure this change is applied where LintViolation and
ViolationLocation are constructed for the UTF8_INTEGRITY case.
- Around line 448-457: When check_utf8_integrity(&file) returns non-empty, the
code should fail-fast instead of continuing to subsequent auto-fix steps; after
emitting the feedback with emit_feedback(...) return early or terminate the
pipeline (e.g. return an Err or call std::process::exit(1)) so that downstream
steps like the formatter/fixer are not run on a corrupted file. Modify the block
that handles utf8_violations to stop further processing (using the same control
flow style as the surrounding function) so no
run_custom_rules/run_formatter/run_fixer steps execute for that file.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 58fcd586-e512-4b89-a456-16f86ca0f549
📒 Files selected for processing (2)
docs/todo.mdsrc/hooks-post-tool-linter/src/main.rs
9b20351 to
f596dbc
Compare
Summary
Changes
hooks-post-tool-linter (
src/hooks-post-tool-linter/src/main.rs)check_utf8_integrity()関数を追加:std::fs::read+String::from_utf8_lossyで U+FFFD を検出main()の最初に実行 (カスタムルール・外部ツールパイプラインより先)docs/todo.md
Background
PR #50 の push 時に takt の fix ステップが日本語文字列を破壊する mojibake が発生 (
"進みます。"→"進みま\uFFFD\uFFFD。")。CodeRabbit が Major として検出したが、PostToolUse hook では防げなかった。本 PR で Edit/Write 直後に即座にフィードバックする仕組みを追加。Test plan
cargo test -p hooks-post-tool-linter全 45 テスト合格 (新規 5 + 既存 40)pnpm build:all成功Summary by CodeRabbit
リリースノート
新機能
ドキュメント