Skip to content

[create-cloudflare] Handle git commit failures gracefully#12269

Merged
penalosa merged 2 commits intomainfrom
fix/6965-git-commit-error-handling
Jan 29, 2026
Merged

[create-cloudflare] Handle git commit failures gracefully#12269
penalosa merged 2 commits intomainfrom
fix/6965-git-commit-error-handling

Conversation

@penalosa
Copy link
Copy Markdown
Contributor

@penalosa penalosa commented Jan 29, 2026

Fixes #6965.

When creating the initial git commit fails (for example, when GPG signing is cancelled or misconfigured), the setup process now continues instead of crashing. A message is displayed informing the user that the commit was skipped and they can commit manually later.

The gitCommit function in packages/create-cloudflare/src/git.ts previously lacked try-catch error handling around the git commit operation, unlike other git-related functions in the same file (e.g., initializeGit, isGitConfigured, isInsideGitRepo, getProductionBranch). This caused the entire C3 setup process to abort when the commit failed.


  • Tests
    • Tests included/updated
    • Automated tests not possible - manual testing has been completed as follows:
    • Additional testing not necessary because:
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: This is a bug fix that doesn't change any documented behavior

Open with Devin

@penalosa penalosa requested a review from a team as a code owner January 29, 2026 14:50
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Jan 29, 2026

🦋 Changeset detected

Latest commit: 0d36d27

The changes in this PR will be included in the next version bump.

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

@claude
Copy link
Copy Markdown
Contributor

claude Bot commented Jan 29, 2026

Claude finished @penalosa's task —— View job


Changeset Review

  • Read changeset guidelines
  • Read changeset file
  • Validate changeset
  • Post review results

All changesets look good

The changeset .changeset/ahdjzkizttbkaudepwzx.md passes all validation criteria:

  • Version Type: Correctly marked as patch (bug fix)
  • Changelog Quality: Clear, meaningful description with context about the problem and solution
  • Markdown Headers: No h1/h2/h3 headers used
  • Package: Correctly targets create-cloudflare
  • Format: Follows the imperative title + explanatory body structure

The changeset appropriately describes this as a bug fix where git commit failures now no longer crash the setup process, and provides good context about the scenario (GPG signing issues).

@penalosa penalosa marked this pull request as draft January 29, 2026 14:51
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 1 potential issue.

View issue and 3 additional flags in Devin Review.

Open in Devin Review

Comment thread packages/create-cloudflare/src/git.ts
Comment thread packages/create-cloudflare/src/git.ts Outdated
} catch {
s.stop(`${brandColor("git")} ${dim(`commit failed`)}`);
updateStatus(
"Failed to create initial commit. Your changes have been staged but not committed. You can commit manually later.",
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@claude the changes may not have been staged, since git add could have failed. Make this error message something like "Failed to create initial commit. You can commit manually later."

Copy link
Copy Markdown
Contributor

@claude claude Bot Jan 29, 2026

Choose a reason for hiding this comment

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

Claude finished @penalosa's task —— View job


Fixed Error Message ✅

Updated the error message to be more accurate since git add could fail before staging any changes.

Todo List:

  • Install dependencies (Not needed for this simple change)
  • Read the current git.ts implementation
  • Update the error message to be more generic
  • Run code quality checks (Simple text change, low risk)
  • Commit and push changes

Analysis: I can see the issue in packages/create-cloudflare/src/git.ts:102. The try-catch block wraps both git add (lines 85-88) and git commit (lines 90-96), but the error message assumes that staging succeeded. If git add fails, the changes would not have been staged, making the message misleading.

Fixed: Updated the error message from:

"Failed to create initial commit. Your changes have been staged but not committed. You can commit manually later."

to:

"Failed to create initial commit. You can commit manually later."

This makes the message accurate regardless of whether git add or git commit failed, addressing the Devin review feedback as well.

Changes pushed to branch fix/6965-git-commit-error-handling


@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Jan 29, 2026

create-cloudflare

npm i https://pkg.pr.new/create-cloudflare@12269

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/@cloudflare/kv-asset-handler@12269

miniflare

npm i https://pkg.pr.new/miniflare@12269

@cloudflare/pages-shared

npm i https://pkg.pr.new/@cloudflare/pages-shared@12269

@cloudflare/unenv-preset

npm i https://pkg.pr.new/@cloudflare/unenv-preset@12269

@cloudflare/vite-plugin

npm i https://pkg.pr.new/@cloudflare/vite-plugin@12269

@cloudflare/vitest-pool-workers

npm i https://pkg.pr.new/@cloudflare/vitest-pool-workers@12269

@cloudflare/workers-editor-shared

npm i https://pkg.pr.new/@cloudflare/workers-editor-shared@12269

@cloudflare/workers-utils

npm i https://pkg.pr.new/@cloudflare/workers-utils@12269

wrangler

npm i https://pkg.pr.new/wrangler@12269

commit: 3716cc5

Make error message generic since git add could also fail

Co-authored-by: Somhairle MacLeòid <penalosa@users.noreply.github.com>
@penalosa penalosa marked this pull request as ready for review January 29, 2026 15:01
@github-project-automation github-project-automation Bot moved this from Untriaged to Approved in workers-sdk Jan 29, 2026
@penalosa penalosa merged commit a1450ca into main Jan 29, 2026
37 of 38 checks passed
@github-project-automation github-project-automation Bot moved this from Approved to Done in workers-sdk Jan 29, 2026
@penalosa penalosa deleted the fix/6965-git-commit-error-handling branch January 29, 2026 18:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

🐛 BUG: The wrangler setup does not proceed to the next step

3 participants