Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

batches: getting changed files in step: applying cached diff: error: unrecognized input: exit status 128 #755

Closed
sfllaw opened this issue May 27, 2022 · 5 comments · Fixed by #778
Assignees
Labels
bug Something isn't working team/code-search

Comments

@sfllaw
Copy link

sfllaw commented May 27, 2022

Sometimes, when updating a batch change that has already been applied, the cached diff cannot be applied:

sfllaw@hostname:~$ src batch apply -v -f batch-changes.yaml 
✅ Parsing batch spec
✅ Resolving namespace
✅ Preparing container images  ██████████████████████████████████████████████
🚧 Workspace creator: bind
✅ Set workspace type
✅ Resolved 137 repositories
✅ Found 137 workspaces with steps to execute
✅ Found 0 cached changeset specs; 137 tasks need to be executed

✅ Executing... (137/137, 24 errored)  ██████████████████████████████████████

❌ 24 errors:
   github.com/sfllaw/repo:
   getting changed files in step: applying cached diff: 'git apply -p0 /home/sfllaw/.cache/sourcegraph/batch/bind-workspace-test-1611338046' failed: error: unrecognized input: exit status 128
   Log: /tmp/changeset-github.com-sfllaw-repo-5e3e8f2c3e2780ec35240790d1971b2c0b7ed9b0.3325954318.log

If we look into the cache, we see that the diff is empty!

sfllaw@hostname:~/.cache/sourcegraph/batch$ jq -C . < github.com-sfllaw-repo-5e3e8f2c3e2780ec35240790d1971b2c0b7ed9b0/j7ViTNOX3Gkk_8XnX-MbZQ.json
{
  "diff": "",
  "changedFiles": {
    "modified": null,
    "added": null,
    "deleted": null,
    "renamed": null
  },
  "outputs": {},
  "path": ""
}

This is exactly the behaviour you’d expect from an empty patch:

sfllaw@hostname:~/src/repo$ echo -n '' > patch
sfllaw@hostname:~/src/repo$ git apply -p0 patch
error: unrecognized input
sfllaw@hostname:~/src/repo$ echo $?
128
@sfllaw
Copy link
Author

sfllaw commented May 28, 2022

@BolajiOlajide
Copy link
Contributor

BolajiOlajide commented May 30, 2022

Hello @sfllaw,

Thanks for reporting this issue.
We've added it to our planning discussion list and we will respond after.

Cheers!

@eseliger eseliger added the bug Something isn't working label Jun 2, 2022
@chrispine chrispine assigned LawnGnome and unassigned LawnGnome Jun 9, 2022
@LawnGnome
Copy link
Contributor

@sfllaw At the risk of causing this to take much longer than it should, does using the -clear-cache flag "fix" the issue? (We're just trying to narrow down where the missing check is, since we should handle empty diffs more gracefully.)

@sfllaw
Copy link
Author

sfllaw commented Jun 9, 2022

@LawnGnome I’ve finished working on this batch change, so I’m unable answer that question. But I’m guessing the answer is yes?

I recommend that an empty cache diff should not create a changeset because there is no change? Skipping seems to be the what happens on a fresh change, so I’d expect the same behaviour on subsequent runs.

@eseliger
Copy link
Member

Found the cause, will fix this in the next release. Thanks for reporting and sorry for the inconvenience :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working team/code-search
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants