Skip to content

fix(controlplane): fallback CAS downloads from invalid backends#3255

Open
waveywaves wants to merge 1 commit into
chainloop-dev:mainfrom
waveywaves:fix/cas-download-backend-fallback
Open

fix(controlplane): fallback CAS downloads from invalid backends#3255
waveywaves wants to merge 1 commit into
chainloop-dev:mainfrom
waveywaves:fix/cas-download-backend-fallback

Conversation

@waveywaves

@waveywaves waveywaves commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Summary

  • fall back from an invalid mapped CAS backend to the org default/fallback backend when minting download credentials
  • apply the same backend selection to browser download redirects
  • add a focused CAS backend use case test

Fixes #3190

Tests

  • SKIP_INTEGRATION=true go test ./app/controlplane/pkg/biz -run TestCASBackend -count=1
  • SKIP_INTEGRATION=true go test ./app/controlplane/internal/service -count=1
  • SKIP_INTEGRATION=true go test ./app/controlplane/internal/service ./app/controlplane/cmd -run TestDoesNotExist -count=1
  • git diff --check

Review in cubic

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

1 issue found across 5 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread app/controlplane/pkg/biz/casbackend_test.go
@waveywaves waveywaves force-pushed the fix/cas-download-backend-fallback branch from 40beb87 to c896cf4 Compare June 30, 2026 13:08
@waveywaves

waveywaves commented Jun 30, 2026

Copy link
Copy Markdown
Contributor Author

Updated tests for Cubic's edge-case feedback: nil mapped backend, missing default, missing fallback, and invalid fallback.

Validation:

SKIP_INTEGRATION=true go test ./app/controlplane/pkg/biz -run TestCASBackend -count=1

}

// FindDownloadBackend returns the mapped backend, or the org default/fallback when the mapped backend is invalid.
func (uc *CASBackendUseCase) FindDownloadBackend(ctx context.Context, mapped *CASBackend) (*CASBackend, error) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I am not sure this meethod is correct since it checks default, not just fallback, do we want to also check default?

@waveywaves waveywaves Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, default-first is intentional here.

CAS mappings are historical (digest -> backend ID). The issue scenario is credential rotation by creating a new backend pointing at the same storage location and making it the org default, while old mappings still point at the backend with revoked credentials.

So for downloads, when the mapped backend is invalid, we try the org's current default backend first, then the configured fallback. This is safe because the CAS download path verifies the content digest; if the default backend does not contain the exact artifact, the download fails.

I added a code comment to make this intent explicit.

Signed-off-by: Vibhav Bobade <vibhav.bobde@gmail.com>
@waveywaves waveywaves force-pushed the fix/cas-download-backend-fallback branch from c896cf4 to 036cd20 Compare July 6, 2026 08:31
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.

Fall back to the org's default CAS backend on artifact download failures

2 participants