Repository navigation
Conversation
saveSnapshot filtered runner images by alias and then unconditionally used runner_images[0]. The list endpoint can return aliases that merely contain the requested one -- querying 'my-image' also matches 'my-image-arm64' -- and the ordering of those results is not guaranteed, so which alias 'wins' varied from run to run. That produced two failure modes: the action could update the wrong snapshot alias, or throw a spurious "isn't supported" arch/os mismatch after picking a sibling image built for a different architecture. Select the image whose alias is exactly equal to the requested alias instead of trusting the first element. When no exact match exists we now fall through to the create path, which is the correct behaviour for a genuinely new alias. Fixes WarpBuilds#86
5cd0122 to
8457870
Compare
|
Rebased on |
|
Hi @jchak7 , we have fixed this on the server side a while ago. The |
Problem
Snapshotter.saveSnapshotlooks up an existing snapshot by alias and then unconditionally uses the first element of the response:listRunnerImagesreturns a list, and the code never checks that any element of it actually is the requested alias — it only checks that the list is non-empty. That is only safe if the endpoint is guaranteed to return exact matches only, in a guaranteed order. Neither is expressed anywhere in this repo, and #86 reports the case where it does not hold: a query formy-imagealso comes back with siblings such asmy-image-arm64.Two concrete failure modes when that happens:
[0]was built for a different architecture, the check immediately below throws... isn't supported ...even though the requested alias is perfectly valid. Same workflow, same inputs, different outcome depending on response ordering.Fix
Select the image whose alias is exactly the requested one, rather than trusting position:
This is correct regardless of what the endpoint's matching semantics turn out to be: if it only ever returns exact matches the behaviour is unchanged, and if it returns anything broader the right element is now picked deterministically.
When no exact match exists the code falls through to the create path, which is the correct behaviour for a genuinely new alias — previously a partial-match sibling would have hijacked it into the update path.
Type-safe against the existing model:
alias?: stringandid: stringare both already present on the runner image type, so no type or API changes are needed.Testing
npx tsc --noEmit— cleannpx jest— 1/1 passingnpx prettier --check— conformantnpm run package—dist/rebuilt and committed socheck-distpasses; the compiled bundle contains thefind(...)selection and no longer containsrunner_images?.[0]Happy to add a unit test covering the sibling-alias case if you'd like one in the same PR.
Fixes #86