Skip to content

Fix error while committing a locked problem with an accepted solution. #59

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

Merged
merged 2 commits into from
May 8, 2024

Conversation

Darshan-AS
Copy link
Contributor

Came across the below error on a recent run:

[Sun, 28 Apr 2024 19:56:01 GMT] Syncing 1480 submissions...
[Sun, 28 Apr 2024 19:56:01 GMT] Got info for submission #321203125
[Sun, 28 Apr 2024 19:56:01 GMT] Getting question data for counting-elements...
[Sun, 28 Apr 2024 19:56:01 GMT] Committing solution for counting-elements...
[Sun, 28 Apr 2024 19:56:01 GMT] HttpError: Must supply either tree.sha or tree.content. Request will be rejected if both are present.
    at /home/runner/work/_actions/joshcai/leetcode-sync/v1.6/dist/index.js:6540:21
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async commit (/home/runner/work/_actions/joshcai/leetcode-sync/v1.6/dist/index.js:14666:24)
    at async Object.sync (/home/runner/work/_actions/joshcai/leetcode-sync/v1.6/dist/index.js:14914:34)
    at async main (/home/runner/work/_actions/joshcai/leetcode-sync/v1.6/dist/index.js:19564:3)
Error: HttpError: Must supply either tree.sha or tree.content. Request will be rejected if both are present.

Turns out the problem counting-elements is a locked/premium problem. As a consequence, fetching the questionData yields null, which then leads to an empty tree.content in the commit, causing the above error.

Interestingly, I do seem to have an accepted solution for the problem in my submission history.
And, No, I wasn't on leetcode premium in the past.

I'm guessing, counting-elements started off as an open problem, but was locked sometime after I'd solved it.

As a hotfix for my personal use, I've wrapped questionData in a template literal. Please feel free to add appropriate fallback text and logs as you deem fit.

Also, shot myself in the foot with the git add . in the pre-commit. Hence a tiny tweak.

PS. Thanks for the good work, Josh. Very nifty tool!

Copy link
Owner

@joshcai joshcai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Darshan-AS for investigating this tricky edge-case and proposing the fix - looks great overall!

@joshcai joshcai merged commit f75ed44 into joshcai:master May 8, 2024
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 this pull request may close these issues.

2 participants