Skip to content

Fix IndexError when parsing malformed git remote output#714

Open
ptanh05 wants to merge 1 commit into
TheKevJames:masterfrom
ptanh05:fix/git-remote-indexerror
Open

Fix IndexError when parsing malformed git remote output#714
ptanh05 wants to merge 1 commit into
TheKevJames:masterfrom
ptanh05:fix/git-remote-indexerror

Conversation

@ptanh05
Copy link
Copy Markdown

@ptanh05 ptanh05 commented May 14, 2026

Summary

  • Fix IndexError in coveralls/git.py when git remote -v produces malformed lines containing (fetch) with fewer than 2 space-separated tokens
  • Add a length guard before indexing into line.split() results in the remotes list comprehension
  • Add regression test to verify the fix

Test plan

  • Run pytest tests/test_git_malformed_remote.py -v to verify the bug is fixed
  • Run pytest tests/ --ignore=tests/git_test.py --ignore=tests/cli_test.py --ignore=tests/api_test.py --ignore=tests/data/ to verify no regressions

git remote -v can produce lines with fewer than 2 space-separated tokens
(e.g., a bare "(fetch)" line), causing the list comprehension in git_info()
to raise an IndexError. Add a length check before accessing split() results
to skip malformed lines gracefully.
@ptanh05 ptanh05 requested a review from TheKevJames as a code owner May 14, 2026 01:17
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