Repository navigation
Avoid using short commit IDs - #1236
Conversation
🦋 Changeset detectedLatest commit: a907e78 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit a907e78:
|
|
Great find @camertron! We've been having exactly the same issue on https://github.com/rrweb-io/rrweb and (thanks to CodeSandbox) I've tested this PR and confirmed it fixes the issue. |
|
@Andarist ok makes sense 👍 Should I make those changes in this PR? |
I think that makes sense. Could you do it @camertron ? |
|
Yeah, it would be cool to do it as part of this PR. |
|
Ok, done! |
Awesome, thanks @camertron! |
|
Thanks for making the requested changes. I'll try to land this soon. It would be great to land #1085 first but I'm not sure if I will have time to finish this PR right now so I might decide just to validate this PR locally. |
My team and I ran into a wild issue with changesets today that has prompted me to open this PR.
Setup
We're using GitHub Actions and saw the following output in one of our release builds:
Looks like it's trying to access the
authorproperty ofnull. After looking at the changesets code, it appears the error happens when processing the result of executing a GraphQL query via the GitHub API. After sticking someconsole.logstatements inside the changesets code, I was able to print out the query:You should be able to copy/paste this query into GitHub's GraphQL explorer and see the following response (modified for brevity):
{ "data": { "a0": { "a51dbba8": null, "a2565a2d": { "commitUrl": "https://github.com/primer/primitives/commit/2565a2d30dbca13b73e21064036910e269385770", "associatedPullRequests": { "nodes": [ { ... } ] }, "author": { "user": { ... } } } } } }Notice the full and complete response for commit
2565a2dbut anullvalue for commit51dbba8.Diagnosis
So what the heck? Running
git rev-parse 51dbba8returns the full commit ID of51dbba881eea1cd1a2d0c601023c9d4b8357b64d, which definitely exists.My only idea, although very unlikely, was a hash collision.
Bingo! There is a hash collision!
51dbba8is a prefix shared by both a commit and a tree object.Using the full SHA (or even just one additional digit) in the GraphQL query returns non-null data for both the commits in question. Problem solved.
Solution
Unless there's a really good reason not to, I think changesets should use full commit IDs everywhere. Since it's a popular project with lots of users, it was only a matter of time before a collision issue like this occurred.
After code spelunking for a few hours, I wasn't able to identify precisely the right part of the code to modify, so I just removed all the instances of
short: truebeing passed into the various git functions. Please let me know if a more nuanced change is necessary.