Skip to content

fix(git-clone): propagate pre/post-clone script failures#891

Open
ikkz wants to merge 1 commit into
coder:mainfrom
ikkz:fix/clone
Open

fix(git-clone): propagate pre/post-clone script failures#891
ikkz wants to merge 1 commit into
coder:mainfrom
ikkz:fix/clone

Conversation

@ikkz
Copy link
Copy Markdown
Contributor

@ikkz ikkz commented May 15, 2026

Description

Fix git-clone module to fail fast when pre_clone_script or post_clone_script returns a non-zero exit code. Previously, both scripts were executed but their exit codes were never checked — a failing pre-clone hook (e.g., a prerequisite check that calls exit 1) was silently ignored and cloning continued. This broke the advertised "validate prerequisites before cloning" behavior and could leave workspaces starting with unmet preconditions.

Type of Change

  • New module
  • New template
  • Bug fix
  • Feature/enhancement
  • Documentation
  • Other

Module Information

Path: registry/coder/modules/git-clone
New version: v1.3.1
Breaking change: [ ] Yes [x] No

Testing & Validation

  • Tests pass (bun test)
  • Code formatted (bun fmt)
  • Changes tested locally

Related Issues

Copy link
Copy Markdown
Collaborator

DevelopmentCats commented May 15, 2026

Hey, thanks for looking into this! The root cause here is actually that run.sh is missing set -euo pipefail at the top, which most of our newer modules already use (claude-code, aider, amazon-q, agent-firewall, dotfiles, etc.). Adding that one line would make the manual if ! guards unnecessary since the script would automatically exit on any non-zero return, and it'd also catch other silent failures we're not handling today (like git clone itself failing, or the base64 -d pipe breaking).

@ikkz Would you be open to swapping the approach to just add set -euo pipefail at the top instead? Smaller diff, catches more cases, and brings this module in line with the rest of the registry.

@ikkz ikkz marked this pull request as draft May 15, 2026 15:33
@ikkz ikkz marked this pull request as ready for review May 16, 2026 04:57
@ikkz
Copy link
Copy Markdown
Contributor Author

ikkz commented May 16, 2026

@DevelopmentCats Updated as suggested.

Added set -euo pipefail to run.sh instead of manually checking the pre/post-clone script exit codes, and added regression tests for failing pre/post-clone hooks.

Also, once this PR is merged, when should we expect the new git-clone module version (v1.3.1) to be published?

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