Skip to content

fix(permissions): ignore NotADirectory and strip BOM before empty check - #4658

Open
webdevsamran wants to merge 1 commit into
rtk-ai:developfrom
webdevsamran:fix/4651-permission-loader-fail-closed
Open

webdevsamran wants to merge 1 commit into
rtk-ai:developfrom
webdevsamran:fix/4651-permission-loader-fail-closed

Conversation

@webdevsamran

Copy link
Copy Markdown

Summary

  • Treat ErrorKind::NotADirectory identical to NotFound when reading Claude Code settings files so non-directory parents (e.g. .claude as a regular file) fail closed instead of triggering unreadable-file warnings and catch-all Ask.
  • Strip leading UTF-8 BOM (\u{feff}) before checking content.trim().is_empty() so BOM-only settings files are correctly treated as empty and skipped rather than failing JSON parsing.
  • Closes Permission loader: a settings file that cannot exist, or holds only a BOM, fails closed #4651.

Test plan

  • Added unit tests in src/hooks/permissions.rs:
    • test_bom_only_settings_file_adds_no_rules: verifies that BOM-only and BOM-plus-whitespace settings files add no rules.
    • test_not_a_directory_settings_file_adds_no_rules: verifies that a settings path under a regular file parent adds no rules without error.
  • Verified cargo fmt --check cleanly.

Important: All PRs must target the develop branch.


AI Disclosure: Implementation assisted by agentic workflow; logic, bounds, and regression tests thoroughly inspected.

Signed-off-by: Samran Asif <samranwebdev2000@gmail.com>
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@rtk-wshm-sync-bot rtk-wshm-sync-bot Bot added bug Something isn't working parsing permissions labels Oct 19, 2026
@rtk-wshm-sync-bot

Copy link
Copy Markdown

wshm · Automated triage by AI

📊 Automated PR Analysis

🐛 Type bug-fix
🟢 Risk low

Summary

Fixes the Claude Code settings permission loader to treat ErrorKind::NotADirectory the same as NotFound (so a non-directory parent like a .claude file fails closed instead of warning/catch-all Ask), and strips a leading UTF-8 BOM before checking if settings content is empty so BOM-only files are skipped rather than failing JSON parsing. Adds two unit tests covering both cases.

Review Checklist

  • Tests present
  • Breaking change
  • Docs updated

Linked issues: #4651


Analyzed automatically by wshm · This is an automated analysis, not a human review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working parsing permissions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Permission loader: a settings file that cannot exist, or holds only a BOM, fails closed

2 participants