Skip to content

batches: fix error handling for github CreateChangeset

Administrator requested to merge es/fix-err-create-changeset-github into main

Created by: eseliger

When the error is NOT a graphqlErrors, the errors.As returns false and does not populate the variable. We then returned it, and the errors.Wrap method further up calls .Error() on the nil slice the graphqlErrors type is under the hood, and in the Error() handler we access e[0]. This panics and causes the confusing error message customers reported:

Creating changeset: %!v(PANIC=Error method: runtime error: index out of range [0] with length 0)

This is not fixing publishing for those changesets, but if fixes that the error is useless. Next up after this fix, we can look into why it's failing and why the returned err doesn't comply with the graphqlErrors type.

This seems to have accidentally slipped in about 11 months ago during an errors refactor. https://github.com/sourcegraph/sourcegraph/pull/22704/files#r866758789

Test plan

Validated that a non graphqlErrors error is not causing this confusing error message anymore by throwing an arbitrary error and comparing before and after the code change results. Works.

Merge request reports

Loading