fix(scanner): guard against nil AckFunc in ackOnce to prevent panic#683
Merged
jem-davies merged 1 commit intowarpstreamlabs:mainfrom Feb 3, 2026
Merged
Conversation
The S3 processor passes nil as AckFunc to Scanner.Create(). When the CSV scanner encounters a non-EOF error, it calls ackOnce(nil) which attempts to invoke nil(ctx, err), resulting in a panic. Add a nil check in ackOnce to safely handle nil AckFunc.
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.
This PR fixes panic in
ackOncewhenAckFuncisnil.The S3 processor passes
nilas theAckFunctoScanner.Create(). When the CSV scanner encounters a non-EOF error (such as a malformed CSV row), it callsackOnce(nil)which attempts to invokenil(ctx, err), resulting in a panic.Root Cause
The issue is in the interaction between:
internal/impl/aws/processor_s3.go:240): Creates a scanner without providing anAckFunc, passingnilinstead.internal/impl/pure/scanner_csv.go): When it encounters a parse error (not EOF), it returns the error.public/service/scanner.go:133): ThemanagedAckBatchScanner.NextBatchcallss.sourceAck(ctx, err)on non-EOF errors.public/service/scanner.go:89): The wrapper doesn't guard against anilunderlying function, leading to the nil pointer dereference.Fix
Add a nil check in
ackOncebefore calling the underlyingAckFunc:Testing
Added unit tests in
public/service/scanner_test.go:TestAutoAggregateBatchScannerAcksWithNilAckFunc- Reproduces the panic scenarioTestAutoAggregateBatchScannerAcksWithNilAckFuncOnClose- Tests Close with nil AckFuncTestAutoAggregateBatchScannerAcksWithValidAckFunc- Ensures normal operation still worksTestAutoAggregateBatchScannerAcksErrorPropagatesAck- Tests error propagationReproduction
Reproduction steps
Prerequisites
Files
docker-compose.yamlnil_ack_panic.yamlSteps
Start MinIO:
Wait for
minio-initto complete:Run the pipeline (before fix - will panic):
Observe the panic: