fix(homeboy): report attach-path results truthfully and resolve project id consistently#169
Merged
Merged
Conversation
…ct id consistently The upgrade's Homeboy component sync reported '0 attached, 45 failed' even though every attach-path call actually succeeded. Two root causes: 1. homeboy_project_id() only resolved from $HOMEBOY_PROJECT_ID or a site-root homeboy.json. On installs without a site-root homeboy.json it returned non-zero, diverging from how 'homeboy project show' / 'attach-path' actually resolve the project (from registered projects by domain). Add a fallback that matches the site domain against 'homeboy project list', so the resolver agrees with what the attach loop targets. Also stop setup_homeboy_project() from caching an empty project id over that fallback. 2. The attach loop trusted the process exit code via '>/dev/null', which did not track Homeboy's real outcome. Parse the JSON '.success' field instead, falling back to the exit code only for non-JSON output. Add homeboy_attach_succeeded() with unit-tested success/fail/non-json cases. Both python invocations pass their JSON payload via env vars rather than stdin, because a heredoc supplying the python source already occupies stdin and would otherwise swallow a piped payload. End-to-end on a Homeboy-enabled install this flips the report from '0 attached, 45 failed' to '45 attached, 0 failed'. Fixes #167
chubes4
added a commit
that referenced
this pull request
May 30, 2026
…tered id (#171) homeboy_project_id() was defined twice — in lib/data-machine.sh and lib/homeboy.sh. upgrade.sh sources data-machine before homeboy, so the homeboy.sh copy won and the data-machine.sh copy (fixed in #169) was dead code. The winning copy's final fallback ran homeboy_slugify on the site domain, turning 'extrachill.com' into 'extrachill' — which is not a registered Homeboy project (the real id is 'extrachill-site'). Homeboy returned {"success": false, "code": "project.not_found"}. This was latent until #169 made the attach loop parse the JSON .success field instead of trusting the exit code: the now-truthful failure tripped upgrade.sh's 'set -e' and aborted the upgrade at exit 4, right after 'Attaching Homeboy components'. Consolidate to a single definition in lib/homeboy.sh (the one that wins by source order) that resolves in priority: $HOMEBOY_PROJECT_ID, site-root homeboy.json, then a domain match against 'homeboy project list' (the real registered id). $AGENT_SLUG and homeboy_slugify remain only as last-ditch setup-time fallbacks for projects not yet registered — they must never win over a real lookup. Remove the shadowed duplicate from data-machine.sh. Verified end-to-end on a Homeboy-enabled install: resolves 'extrachill-site' and the attach loop completes '45 attached, 0 failed' (exit 0) instead of aborting at exit 4. Setup-time unregistered domains still slugify as before. Fixes #170
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
homeboy_project_id()now falls back to matching the site domain againsthomeboy project listwhen there's no site-roothomeboy.jsonand$HOMEBOY_PROJECT_IDis unset — so the resolver agrees with howhomeboy project show/attach-pathactually resolve the project.setup_homeboy_project()no longer caches an empty project id over that fallback..successfield (via newhomeboy_attach_succeeded()) instead of trusting the process exit code through>/dev/null, falling back to the exit code only for non-JSON output. Failure output is now surfaced (first 3 lines) for diagnosis.Why
On a Homeboy-enabled VPS install, the upgrade's Phase 5 component sync reported:
…even though
homeboy project components attach-pathsucceeds when run manually (exit 0,{"success": true, ...}). Two root causes:homeboy_project_id()only knew about$HOMEBOY_PROJECT_ID/ site-roothomeboy.json. This install has neither, so it returned non-zero — yetattach-pathresolves the project from the registered project set by domain (extrachill.com→extrachill-site). The resolver and the actual attach target disagreed.if homeboy ... >/dev/null; thendidn't reflect Homeboy's real outcome.Implementation note
Both python helpers pass their JSON payload via env var, not stdin — a heredoc supplying the python source already occupies stdin, so a piped payload would be silently swallowed (verified this was the actual failure mode while developing the fix).
Verification
Unit-tested
homeboy_attach_succeededacross success /success:false/ non-JSON+exit1 / non-JSON+exit0 / empty / leading-log-lines cases — all correct.End-to-end on this install, the report flips from
0 attached, 45 failedto:Worktrees (
repo@branch) and repos withouthomeboy.jsonare still correctly skipped.Fixes #167