Skip to content

fix(homeboy): report attach-path results truthfully and resolve project id consistently#169

Merged
chubes4 merged 1 commit into
mainfrom
fix-167-homeboy-attach-reporting
May 30, 2026
Merged

fix(homeboy): report attach-path results truthfully and resolve project id consistently#169
chubes4 merged 1 commit into
mainfrom
fix-167-homeboy-attach-reporting

Conversation

@chubes4

@chubes4 chubes4 commented May 30, 2026

Copy link
Copy Markdown
Member

Summary

  • homeboy_project_id() now falls back to matching the site domain against homeboy project list when there's no site-root homeboy.json and $HOMEBOY_PROJECT_ID is unset — so the resolver agrees with how homeboy project show / attach-path actually resolve the project.
  • setup_homeboy_project() no longer caches an empty project id over that fallback.
  • The attach loop now parses Homeboy's JSON .success field (via new homeboy_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:

Homeboy component sync complete: 0 attached, 75 skipped, 45 failed

…even though homeboy project components attach-path succeeds when run manually (exit 0, {"success": true, ...}). Two root causes:

  1. Resolver divergence. homeboy_project_id() only knew about $HOMEBOY_PROJECT_ID / site-root homeboy.json. This install has neither, so it returned non-zero — yet attach-path resolves the project from the registered project set by domain (extrachill.comextrachill-site). The resolver and the actual attach target disagreed.
  2. Exit-code-only success check. if homeboy ... >/dev/null; then didn'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_succeeded across 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 failed to:

Homeboy component sync complete: 45 attached, 77 skipped, 0 failed

Worktrees (repo@branch) and repos without homeboy.json are still correctly skipped.

Fixes #167

…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 chubes4 merged commit 6428875 into main May 30, 2026
4 checks passed
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
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.

Homeboy component sync: upgrade reports '45 failed: homeboy attach-path failed' but attach-path actually succeeds

1 participant