fix: Use PUT method for GitHub file operations to handle non-existent directories #4079
+3
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR fixes an issue where the CLI fails to create files in non-existent directories when using the GitHub API, specifically when test publishing a plugin.
Problem
When running
npx elizaos plugin publish --test
on a fresh fork, the CLI tries to use the POST method to create files in non-existent directories, which fails with 404 errors. However, using PUT works successfully for the same operation.Solution
Modified the
updateFile
function to always use the PUT method instead of conditionally using POST/PUT based on file existence. The GitHub API handles PUT requests more reliably when creating files in directories that don't exist yet.Testing
Tested by:
npx elizaos plugin publish --test
with the original code (fails)This change ensures a consistent experience for users without requiring them to run commands in a specific order.