Skip to content

fix: add errors="replace" to all subprocess.run calls in incremental.py#566

Open
lininn wants to merge 1 commit into
tirth8205:mainfrom
lininn:fix/unicode-decode-error-git-branch
Open

fix: add errors="replace" to all subprocess.run calls in incremental.py#566
lininn wants to merge 1 commit into
tirth8205:mainfrom
lininn:fix/unicode-decode-error-git-branch

Conversation

@lininn

@lininn lininn commented Jun 18, 2026

Copy link
Copy Markdown

Prevents UnicodeDecodeError when git output contains non-UTF-8 or truncated multi-byte characters (e.g., branch names with CJK characters that get truncated by git rev-parse --abbrev-ref HEAD).

The _git_branch_info function was crashing at full_build because it lacked errors='replace' on subprocess.run() calls, while other functions in the same file (e.g., _get_svn_changed_files, _read_ignore_file) already used errors='replace'.

Also adds UnicodeDecodeError to except clauses so that any remaining decode failures are handled gracefully rather than crashing the build.

Closes #302

Pull Request

Linked issue

Closes #

What & why

How it was tested

uv run pytest tests/ --tb=short -q
uv run ruff check code_review_graph/
uv run mypy code_review_graph/ --ignore-missing-imports --no-strict-optional

Checklist

  • Tests added for new functionality
  • All tests pass: uv run pytest tests/ --tb=short -q
  • Linting passes: uv run ruff check code_review_graph/
  • Type checking passes: uv run mypy code_review_graph/ --ignore-missing-imports --no-strict-optional
  • Lines are at most 100 characters
  • Docs updated where behavior changed (README, docs/, docstrings)

Prevents UnicodeDecodeError when git output contains non-UTF-8 or
truncated multi-byte characters (e.g., branch names with CJK characters
that get truncated by git rev-parse --abbrev-ref HEAD).

The _git_branch_info function was crashing at full_build because it
lacked errors='replace' on subprocess.run() calls, while other
functions in the same file (e.g., _get_svn_changed_files,
_read_ignore_file) already used errors='replace'.

Also adds UnicodeDecodeError to except clauses so that any remaining
decode failures are handled gracefully rather than crashing the build.

Closes tirth8205#302
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