fix: prevent Sprites commands from using a different account than the API - #1776
fix: prevent Sprites commands from using a different account than the API#1776aezell wants to merge 1 commit into
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Maintainer triage at The account/endpoint binding and moving identity checks before bootstrap address real bugs. One pre-existing adoption gap remains in this changed path: Before landing, the final candidate still needs real create → sync/run → destroy proof, configured-account/endpoint routing despite conflicting ambient context, and an already-deleted retry with independent native absence plus local claim/key cleanup. The existing native-CLI/fake-token test is useful routing proof but does not replace that lifecycle evidence. No provider resources or credentials were changed during this triage. |
|
I prepared and reviewed the follow-up repair on a maintainer branch: 6a81035. It preserves the original contributor commit and credit and integrates current main. A normal push to the original fork branch was denied by GitHub despite The repair closes two pre-bootstrap ownership gaps in this changed path. Fully labeled resources without a local claim require explicit Five claimless cases and three raw-alias cases reproduced the unsafe behavior before the fixes. The final Sprites/shared race suites, targeted core SSH/copy/secret-boundary race tests, Two proof boundaries remain before landing: a real configured-account create → sync/run → destroy lifecycle with already-deleted retry and independent zero-residue checks, and a working conflicting saved-credential context. The local machine has no configured Sprites account. The docs-derived inline-token fixture was not accepted by this CLI; no keyring entries or new tokens were created to work around that. The maintainer branch is ready for the original branch to incorporate once writable, and the original live-proof gate remains in place. |
|
The saved-file-context isolation proof gap is now closed for the maintainer repair at 6a81035. This does not prove OS Keychain credential resolution or replace the required real-provider lifecycle proof. I tested the official native Sprite CLI The focused race-enabled Go test passed in 2.001s. It used a test-only overlay on the unchanged repair commit, not an additional committed test or a new CI result. The native CLI was SHA-256 pinned to The original contributor branch remains unchanged because the maintainer push was denied. Actual account-backed create/sync/run/destroy and already-deleted cleanup proof are still pending access. No live Sprite resources were created by these checks, and this PR has not been landed. |
I work for Fly. Thanks for including this Sprites implementation in crabbox. Sprites are moving quickly and I found a few inconsistencies in the implementation. This PR should fix those issues to line up with where Sprites are now.
What Problem This Solves
Fixes an issue where users configuring Crabbox's Sprites token or API URL would see bootstrap or SSH commands use a different saved CLI context or ambient endpoint than the API client. It also fixes lease reuse performing bootstrap before checking saved resource identity, status unexpectedly bootstrapping a Sprite, and local cleanup getting stuck after the Sprite had already been deleted.
Why This Change Was Made
Bind Sprites CLI execution and SSH proxy subprocesses to the API client's resolved endpoint and credential, validate existing ownership before bootstrap, and make status observational unless SSH readiness is explicitly requested. On a missing Sprite, clean up only after confirming the original organization and rechecking absence; ambiguous or failed verification preserves the exact local claim and key.
Provider-specific logic stays in the Sprites adapter. Small provider-neutral changes ensure copy probes, archive copies, and local tunnels honor existing SSH child-environment overrides, and keep those potentially credential-bearing overrides out of serialized lease targets.
User Impact
--reclaimdoes not override a recorded immutable resource mismatch.statusis API-only and does not wake or modify the Sprite. Itsreadyfield is false without a probe.status --waitprobes with the existing key but never installs or repairs SSH; normal reuse retries bootstrap.stopafter an already-completed deletion can remove the claim and key. Wrong-account, incomplete-identity, authorization, service-error, and resource-reappearance cases retain local state for retry.crabbox sshstill need the native Sprite CLI environment;crabbox connectcarries Crabbox's resolved environment automatically.Evidence
Passing locally on macOS:
go test -race -count=1 ./internal/providers/sprites ./internal/providers/sharedgo test -race -count=1 ./internal/cli -run 'TestResolvedSSHCopyHelpersApplyTargetEnvironment|TestSSHForwardBoundaryPrivateSessionControl'go test -race -count=1 ./internal/cli -run 'TestResolvedSSH|TestSSHForwardBoundaryPrivateSessionControl|TestSSHTransfer|TestPondSecretBoundaryChildEnvironment'CRABBOX_TEST_SPRITE_CLI=1 go test -race -count=1 ./internal/providers/sprites -run TestSpritesRealCLIUsesConfiguredEndpointAndTokengo vet ./...The optional installed-CLI test uses fake tokens and local HTTP endpoints to verify actual
sprite execandsprite proxyrouting despite conflicting ambient settings. Other regressions cover identity rejection before bootstrap, valid reuse/adoption, non-mutating status with and without a stored key, and the missing-resource cleanup/error matrix.Full-suite result:
go test -race -timeout=15m -p 4 ./...passed the provider packages, including Sprites, but failed in core checkpoint tests and reached the 15-minute timeout inTestRunCoordinatorCleanupOutcomes. These are not reported as green. On clean upstreama0fd5b8da0e0a4f21d21fe0bab6a7ef0ee58e4d4on the same machine, the representative checkpoint failure and the coordinator SSH-wait hang reproduced with:The first fails with the same
writer lost its cancellation statuserror while waiting for fixture SSH; the second times out in the samewaitForSSHReadystack. No unrelated core fixes are included here.This remains a draft because the live Sprites lifecycle smoke is outstanding. No cloud resources or real provider credentials were used for these tests.
Contributor changelog edits are intentionally left to maintainers, per
AGENTS.md.