Skip to content

Conversation

@jjbustamante
Copy link
Member

Summary

Fixes #1590

For Platform API 0.14+, the restorer now validates the already-selected run image from analyzed.toml without retrying the primary image first.

Problem

When using Platform API 0.14 with the -run flag, the restorer's runImageAccessCheck method would:

  1. Read the selected run image from analyzed.toml (e.g., localhost:5000/pack-test/run - a mirror)
  2. Call runToml.FindByRef() which returns the full entry including primary + mirrors
  3. Call BestRunImageMirrorFor() which tries the primary image first
  4. Fail with 401 when the primary is inaccessible, even though the mirror was already selected

This violated the Platform API 0.14 spec which states the restorer should "resolve mirrors for the run-image in analyzed.toml" - meaning validate the already-selected image, not redo selection.

Solution

  • Added ResolveRunImageFromAnalyzed() function in platform/run_image.go that:

    • Takes the already-selected run image from analyzed.toml
    • Validates ONLY that specific image is accessible
    • Does NOT retry with the primary image
    • Returns helpful error messages including the image name
  • Updated runImageAccessCheck() in cmd/lifecycle/restorer.go to use the new function for Platform API 0.14+

  • Added comprehensive tests covering:

    • Main fix: should use already-selected mirror without checking primary
    • Edge case: extensions switching run image
    • Error case: selected mirror becomes inaccessible

Testing

  • ✅ All 23 run image tests pass (20 existing + 3 new)
  • ✅ Test reproduces the bug (initially failed)
  • ✅ Test validates the fix (now passes)
  • ✅ No breaking changes to Platform API < 0.14

Test Plan

The acceptance test in buildpacks/pack#2516 (acceptance/acceptance_test.go:1228-1253) should now pass with this fix.

🤖 Generated with Claude Code

@jjbustamante jjbustamante requested a review from a team as a code owner February 12, 2026 13:10
@jjbustamante jjbustamante force-pushed the jjbustamante/fix/issue-1590-restorer-mirror-selection branch from 95f3b8b to f8ef0bc Compare February 12, 2026 13:13
For Platform API 0.14+, the restorer should validate the already-selected
run image from analyzed.toml without retrying the primary image first.

This fixes issue #1590 where the restorer's runImageAccessCheck would call
BestRunImageMirrorFor with the full entry (primary + mirrors), causing it
to attempt accessing the inaccessible primary image before trying the
already-selected mirror.

Changes:
- Add ResolveRunImageFromAnalyzed function to validate selected mirror
- Update restorer to use new function for Platform API 0.14+
- Add comprehensive tests covering the fix and edge cases
- Improve error messages to include image name for better debugging

Fixes #1590

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Juan Bustamante <bustamantejj@gmail.com>
@jjbustamante jjbustamante force-pushed the jjbustamante/fix/issue-1590-restorer-mirror-selection branch from f8ef0bc to 14bd5aa Compare February 12, 2026 13:21
@jjbustamante jjbustamante self-assigned this Feb 12, 2026
@jjbustamante jjbustamante added the type/bug Something isn't working label Feb 12, 2026
Copy link
Contributor

@jabrown85 jabrown85 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work!

@jabrown85 jabrown85 merged commit 65776df into main Feb 12, 2026
6 checks passed
@jabrown85 jabrown85 deleted the jjbustamante/fix/issue-1590-restorer-mirror-selection branch February 12, 2026 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Restorer fails to use selected mirror when extending run image (Platform API 0.14)

2 participants