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

Commits may fail to be deserialized because sha field may be null in DiffEntry if contents did not change #749

Open
fiadliel opened this issue Feb 1, 2025 · 0 comments · May be fixed by #750

Comments

@fiadliel
Copy link

fiadliel commented Feb 1, 2025

When a commit includes file(s) that have no changes to the contents, the sha field is null. e.g. the file mode changed from 100644 to 10755.

When trying to parse the commit response, this error shows up:

Json { source: Error { path: Path { segments: [Map { key: "files" }, Seq { index: 0 }, Map { key: "sha" }] }, original: Error("invalid type: null, expected a string", line: 1, column: 4929) }

Looking at the code, this can only happen with the sha field of the DiffEntry struct. If I modify the code to make this field optional, the request works.

I note that this behavior actually differs from what GitHub claim here: https://docs.github.com/en/rest/commits/commits?apiVersion=2022-11-28#get-a-commit
It says that sha is a required field, but that doesn't appear to be the case in this one situation.

Image

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 a pull request may close this issue.

1 participant