Summary
The pkg/recipe.DataProvider interface methods (ReadFile, WalkDir) do not accept context.Context, so catalog and overlay file I/O cannot be cancelled or timed out by callers that hold a context. Adding context propagation through the interface and all implementations (EmbeddedDataProvider, LayeredDataProvider, MemoryDataProvider) would let validator and recipe-loader entry points honor their surrounding context deadline on the I/O path.
Motivation
coderabbitai flagged this on #1107:
Thread a timeout-bounded context into catalog load I/O. At Line 76, catalog file I/O is unbounded (dp.ReadFile(...)) and LoadWithDataProvider does not accept context.Context, so callers cannot enforce cancellation/timeout on this read path.
The concern is legitimate but the fix is out of scope for #1107 (a refactor preserving the pre-existing Load(version, commit) signature). The interface change ripples through:
pkg/recipe.DataProvider interface methods
EmbeddedDataProvider, LayeredDataProvider, MemoryDataProvider implementations
catalog.LoadWithDataProvider, catalog.Load shim
recipe.LoadFromFileWithProvider, recipe.LoadFromFile shim
- Any external
DataProvider implementers (Public (evolving) tier — see docs/integrator/public-api.md)
Impact today
Pre-existing — not a new regression from #1107. Risk: a hung NFS / sshfs read on --data directory under a slow network mount would block the validator goroutine until process termination, since the surrounding ValidatePhases(ctx) cancellation cannot interrupt the in-flight ReadFile.
Embedded reads cannot hang. Local-disk reads on a healthy filesystem are bounded by defaults.MaxExternalDataFileBytes + io.LimitReader. The exposure is narrow but real for network-backed --data mounts.
Acceptance
Related
Summary
The
pkg/recipe.DataProviderinterface methods (ReadFile,WalkDir) do not acceptcontext.Context, so catalog and overlay file I/O cannot be cancelled or timed out by callers that hold a context. Adding context propagation through the interface and all implementations (EmbeddedDataProvider,LayeredDataProvider,MemoryDataProvider) would let validator and recipe-loader entry points honor their surrounding context deadline on the I/O path.Motivation
coderabbitai flagged this on #1107:
The concern is legitimate but the fix is out of scope for #1107 (a refactor preserving the pre-existing
Load(version, commit)signature). The interface change ripples through:pkg/recipe.DataProviderinterface methodsEmbeddedDataProvider,LayeredDataProvider,MemoryDataProviderimplementationscatalog.LoadWithDataProvider,catalog.Loadshimrecipe.LoadFromFileWithProvider,recipe.LoadFromFileshimDataProviderimplementers (Public (evolving) tier — seedocs/integrator/public-api.md)Impact today
Pre-existing — not a new regression from #1107. Risk: a hung NFS / sshfs read on
--datadirectory under a slow network mount would block the validator goroutine until process termination, since the surroundingValidatePhases(ctx)cancellation cannot interrupt the in-flightReadFile.Embedded reads cannot hang. Local-disk reads on a healthy filesystem are bounded by
defaults.MaxExternalDataFileBytes+io.LimitReader. The exposure is narrow but real for network-backed--datamounts.Acceptance
DataProvider.ReadFile/WalkDiracceptcontext.Contextas first parameterctx.Err()between file opens; Memory same)catalog.LoadWithDataProvider,recipe.LoadFromFileWithProvider, etc. take and propagatectxValidatePhases,ValidatePhase) pass their incomingctxthrough to the catalog loadcatalog.Load,recipe.LoadFromFile) boundcontext.Background()with a timeout frompkg/defaultsReadFilereturnscontext.Canceledwhen the caller cancels mid-readRelated