Skip to content

Ignore files with a UTF-8 BOM: first pattern silently dropped (git honors it, graphify does not) #2163

Closed

Description

Affected version

  • graphifyy 0.9.25 (uv tool install)
  • Windows 11, PowerShell 5.1 + Git for Windows

Summary

.gitignore and .graphifyignore are parsed without stripping a leading UTF-8 BOM. When the file is BOM-encoded, the first pattern is silently dropped — it is read as <BOM><pattern>, which matches nothing.

Git itself strips the BOM, so a file git honors is silently ignored by graphify. There is no warning.

This is easy to hit on Windows: PowerShell 5.1's Set-Content -Encoding utf8 — the most obvious way to write the file — emits a BOM.

Reproduce

Fixture: a repo with keep/a.py plus five .py files under .fable-wt/wt1/.

# BOM-free
[System.IO.File]::WriteAllText("$t\.graphifyignore", ".fable-wt/`n", (New-Object System.Text.UTF8Encoding($false)))
graphify . --code-only     # -> found 1 code    CORRECT

# identical content, with BOM
[System.IO.File]::WriteAllText("$t\.graphifyignore", ".fable-wt/`n", (New-Object System.Text.UTF8Encoding($true)))
graphify . --code-only     # -> found 6 code    PATTERN SILENTLY IGNORED

# what a Windows user actually types
Set-Content -Path "$t\.graphifyignore" -Value ".fable-wt/" -Encoding utf8
graphify . --code-only     # -> found 6 code    PATTERN SILENTLY IGNORED

Measured:

ignore file encoding found N code
none (baseline) — 6
.graphifyignore UTF-8, no BOM 1
.graphifyignore UTF-8, with BOM 6
.graphifyignore PS -Encoding utf8 6

Divergence from git

Same pattern, same BOM, in .gitignore:

git honors BOM'd .gitignore:     True
git honors non-BOM .gitignore:   True
graphify w/ BOM'd .gitignore:    1 code file found (expected 0)

graphify documents that it honors .gitignore, but diverges from git on BOM-encoded files.

Impact

Silent. On a monorepo where the intended exclusion is a worktree root, dropping that one pattern is the difference between indexing one copy of the tree and indexing 100+. In my case the first pattern was .fable-wt/ against 111 worktrees; the run went from seconds to 27+ minutes of CPU with no indication the ignore file was not in effect.

Possibly related: #1958 (detect() CPU-bound 35+ min on large monorepo).

Suggested fix

Read ignore files with utf-8-sig, which transparently handles both BOM and BOM-free input. In detect.py, in the per-directory reader and _load_graphifyignore:

text = path.read_text(encoding="utf-8-sig")

Optionally also warn when an ignore file is BOM-encoded, since the failure is otherwise invisible.

Activity

  1. safishamsi commented on Jul 24, 2026

    @safishamsi
    Member

    Fixed in v0.9.26. .gitignore/.graphifyignore/info/exclude are now read with utf-8-sig, so a leading UTF-8 BOM is stripped (matching git) and the first pattern is honored instead of silently dropped. https://github.com/Graphify-Labs/graphify/releases/tag/v0.9.26

  2. added a commit that references this issue on Jul 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions