Skip to content

Commit 9225d5e

Browse files
committed
fix(devcontainer): harden marketplace registration error handling
Address code review findings in register-plugin-marketplaces.sh: surface jq parse errors instead of silently swallowing them, capture CLI output to prevent noisy terminal interleaving, add 30s timeout to prevent hung registrations, and switch from pipe-to-while to here-string pattern. Add ordering dependency comment to post-create.sh.
1 parent 7e41ab8 commit 9225d5e

2 files changed

Lines changed: 12 additions & 5 deletions

File tree

‎image/scripts/post-create.sh‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ pnpm install -g "@google/gemini-cli@${GEMINI_CLI_VERSION}"
104104
echo "✓ CLI tools installed"
105105

106106
# Step 6: Register plugin marketplaces from project settings
107+
# NOTE: Must run BEFORE firewall init (step 10) — marketplace registration
108+
# clones git repos and needs unrestricted network access.
107109
echo ""
108110
echo "[6/12] Registering plugin marketplaces..."
109111
/usr/local/bin/register-plugin-marketplaces.sh "$WORKSPACE_ROOT"

‎image/scripts/register-plugin-marketplaces.sh‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,28 @@ if [ ! -f "$PROJECT_SETTINGS" ]; then
2424
fi
2525

2626
# Extract git URLs from extraKnownMarketplaces
27-
URLS=$(jq -r '
27+
if ! URLS=$(jq -r '
2828
.extraKnownMarketplaces // {} |
2929
to_entries[] |
3030
select(.value.source.source == "git") |
3131
.value.source.url
32-
' "$PROJECT_SETTINGS" 2>/dev/null)
32+
' "$PROJECT_SETTINGS" 2>&1); then
33+
echo " ⚠ Failed to parse $PROJECT_SETTINGS: $URLS"
34+
exit 0
35+
fi
3336

3437
if [ -z "$URLS" ]; then
3538
echo " No extraKnownMarketplaces defined in project settings"
3639
exit 0
3740
fi
3841

39-
echo "$URLS" | while read -r url; do
42+
# Registration is idempotent-safe: failures (including duplicates) are logged but non-fatal
43+
while IFS= read -r url; do
4044
echo " Registering marketplace: $url"
41-
if claude plugin marketplace add "$url" 2>&1; then
45+
if output=$(timeout 30 claude plugin marketplace add "$url" 2>&1); then
4246
echo " ✓ Registered: $url"
4347
else
4448
echo " ⚠ Failed to register: $url"
49+
echo " $output"
4550
fi
46-
done
51+
done <<< "$URLS"

0 commit comments

Comments
 (0)