You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR addresses a ValueError: not enough values to unpack occurring in shared/torngit/base.py within the diff_to_json function.
Problem:
When processing certain malformed diff headers, specifically those where filenames contain spaces (e.g., "${ dir}/definition.yaml"), the _diff.pop(0).split(" b/", 1) operation can return a single-element list. Attempting to unpack this into before, after raises a ValueError. The existing try/except block only caught IndexError, allowing the ValueError to propagate and crash app.tasks.pulls.Sync tasks.
Solution:
Modified the except clause on line 154 of libs/shared/shared/torngit/base.py from except IndexError: to except (IndexError, ValueError):. This change ensures that ValueError exceptions, caused by malformed diff headers, are also caught. The existing fallback logic within the except block (which scans for --- a/ and +++ b/ lines) correctly handles these cases, preventing task crashes and allowing the diff parsing to proceed as intended.
Legal Boilerplate
Look, I get it. The entity doing business as "Codecov" is owned by Harness, Inc. In 2026 Harness acquired Codecov and as a result Harness is going to need some rights from me in order to utilize my contributions in this PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Harness can use, modify, copy, and redistribute my contributions, under Harness's choice of terms.
This PR widens the except IndexError: clause in diff_to_json (libs/shared/shared/torngit/base.py:154) to except (IndexError, ValueError):, so malformed diff headers whose filename line lacks a b/ separator no longer crash app.tasks.pulls.Sync. The existing fallback that scans for --- a/ / +++ b/ correctly handles the ValueError case — _diff.pop(0) has already run before .split() raises, so the header lines the fallback needs are still present in _diff. The change is minimal, correctly targeted, and low-risk.
❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 91.63%. Comparing base (17e0f08) to head (b370e3d).
✅ All tests successful. No failed tests found.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR addresses a
ValueError: not enough values to unpackoccurring inshared/torngit/base.pywithin thediff_to_jsonfunction.Problem:
When processing certain malformed diff headers, specifically those where filenames contain spaces (e.g.,
"${ dir}/definition.yaml"), the_diff.pop(0).split(" b/", 1)operation can return a single-element list. Attempting to unpack this intobefore, afterraises aValueError. The existingtry/exceptblock only caughtIndexError, allowing theValueErrorto propagate and crashapp.tasks.pulls.Synctasks.Solution:
Modified the
exceptclause on line 154 oflibs/shared/shared/torngit/base.pyfromexcept IndexError:toexcept (IndexError, ValueError):. This change ensures thatValueErrorexceptions, caused by malformed diff headers, are also caught. The existing fallback logic within theexceptblock (which scans for--- a/and+++ b/lines) correctly handles these cases, preventing task crashes and allowing the diff parsing to proceed as intended.Legal Boilerplate
Look, I get it. The entity doing business as "Codecov" is owned by Harness, Inc. In 2026 Harness acquired Codecov and as a result Harness is going to need some rights from me in order to utilize my contributions in this PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Harness can use, modify, copy, and redistribute my contributions, under Harness's choice of terms.
Fixes WORKER-PK2
This PR was automatically generated by Sentry. You can adjust this setting at any time.