Merged
Conversation
Convert OCI unpack panics into ordinary image build failures and add a regression test from the captured hypeman-test fixture so interrupted build recovery cannot take down hypeman startup. Made-with: Cursor
Keep only the single manifest entry needed for the recovery regression so the fixture stays small while preserving the host failure case. Made-with: Cursor
Route 20-second integration waits through the existing CI-aware timeout helper so Linux runners get the extra slack already intended for startup-heavy VM lifecycle tests. Made-with: Cursor
Detect malformed image configs before calling umoci so recovered builds fail cleanly without relying on panic recovery for the captured diff_ids mismatch case. Made-with: Cursor
Add a short comment explaining which malformed config conditions we reject before calling umoci. Made-with: Cursor
sjmiller609
approved these changes
Mar 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
hypeman-testrecovery fixture throughunpackLayers()andRecoverInterruptedBuilds()Smoking Gun From The Dev Host
dev-yul-hypeman-1, recoveredhypeman-test:*builds repeatedly crashed hypeman with:panic: runtime error: index out of range [0] with length 0github.com/opencontainers/umoci/oci/layer.UnpackRootfs ... unpack.go:259github.com/kernel/hypeman/lib/images.(*ociClient).unpackLayers ... oci.gogithub.com/kernel/hypeman/lib/images.(*manager).RecoverInterruptedBuilds.func2 ... manager.goMar 28 18:49:07 ... panic: runtime error: index out of range [0] with length 0... github.com/opencontainers/umoci/oci/layer.UnpackRootfs ... unpack.go:259... github.com/kernel/hypeman/lib/images.(*ociClient).unpackLayers ...... github.com/kernel/hypeman/lib/images.(*manager).RecoverInterruptedBuilds.func2 ...{"architecture":"amd64","os":"linux","config":{},"rootfs":{"type":"layers","diff_ids":[]}}Investigation
umociv0.6.0,oci/layer/unpack.go:259doeslayerDiffID := config.RootFS.DiffIDs[idx]with no bounds check.config.RootFS.Type == "layers"butlen(config.RootFS.DiffIDs) == 0whilelen(manifest.Layers) == 1, soumocipanics instead of returning an error.umoci, this PR now validates the config/manifest relationship up front and returns a normal error.recover()wrappers in our code to handle this case.unpackLayers()now passes the callerctxintoumociinstead ofcontext.Background(). That change is intentional and orthogonal to the panic fix: it preserves cancellation/timeout propagation from the enclosing build or recovery flow. Usingcontext.Background()would ignore caller cancellation and could let unpacking continue after the surrounding operation had already timed out, been canceled, or started shutting down.Test plan
go test ./lib/images -run 'TestUnpackLayersCapturedFixtureReturnsErrorInsteadOfPanicking|TestRecoverInterruptedBuildsCapturedFixtureMarksBuildFailed'go test ./lib/imagesgo test ./lib/instances -run 'TestWaitForState_SubscriptionDelivers|TestWaitForState_ChannelClosedOnDelete|TestWaitForState_TerminalViaSubscription|TestWaitForState_ShutdownIsTerminal|TestWaitForState_PausedIsTerminal|TestWaitForProcessExit_TimesOutForRunningProcess' -count=1Made with Cursor
Note
Medium Risk
Moderate risk because it changes the image layer unpack path used during pulls and recovery; validation may cause previously-tolerated malformed images to fail earlier, but it’s limited to defensive checks and improved context propagation.
Overview
Prevents hypeman from crashing during startup recovery when unpacking malformed OCI images by validating the image config before calling
umociand returning a normal error instead of hitting an out-of-bounds panic;unpackLayersalso now passes through the callerctxtolayer.UnpackRootfs.Adds a regression test plus a captured on-disk OCI cache fixture to ensure
unpackLayers()andRecoverInterruptedBuilds()fail the build cleanly for the malformed config case.Adjusts multiple instance integration tests to route 20-second
waitForInstanceStatecalls through the existing CI-awareintegrationTestTimeouthelper for more reliable timings on CI runners.Written by Cursor Bugbot for commit 3124580. This will update automatically on new commits. Configure here.