Skip to content

fix(batch): add optional logger injection for BatchProcessors (#7553)#8272

Open
Sujit-1509 wants to merge 4 commits into
aws-powertools:developfrom
Sujit-1509:fix/batch-processor-logger-injection
Open

fix(batch): add optional logger injection for BatchProcessors (#7553)#8272
Sujit-1509 wants to merge 4 commits into
aws-powertools:developfrom
Sujit-1509:fix/batch-processor-logger-injection

Conversation

@Sujit-1509

@Sujit-1509 Sujit-1509 commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

Issue number: closes #7553

Summary

Closes #7553.

Changes

This PR adds optional logger injection to the Batch Processing utility, allowing record-processing exceptions to be logged with their original traceback when desired.

Implementation

  • Added an optional \logger: Logger | logging.Logger | None\ parameter to the batch processor hierarchy.

  • Updated \ ailure_handler()\ to emit a warning with \exc_info\ when:

    • a logger is provided, and
    • the exception contains a real traceback.
  • Preserved existing behavior when no logger is supplied.

  • Added regression tests covering:

    • exception logging with an injected logger,
    • backward compatibility when no logger is provided,
    • FIFO circuit-breaker scenarios to ensure synthetic exceptions are not logged.

Why logger injection?

This follows existing Powertools dependency-injection patterns and avoids introducing additional boolean configuration flags or undocumented APIs.

User Experience

Before:

  • Record-processing exceptions were stored internally but not emitted through a customer logger.

After:

  • Customers can provide a logger to the processor and receive warning logs with full traceback information for failed records.
  • Existing behavior remains unchanged unless a logger is explicitly provided.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.

@Sujit-1509 Sujit-1509 requested a review from a team as a code owner June 14, 2026 03:56
@Sujit-1509 Sujit-1509 requested a review from svozza June 14, 2026 03:56
@boring-cyborg boring-cyborg Bot added documentation Improvements or additions to documentation tests labels Jun 14, 2026
@powertools-for-aws-oss-automation powertools-for-aws-oss-automation Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jun 14, 2026
@powertools-for-aws-oss-automation powertools-for-aws-oss-automation Bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jun 14, 2026
@powertools-for-aws-oss-automation powertools-for-aws-oss-automation Bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jun 14, 2026
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/L Denotes a PR that changes 100-499 lines, ignoring generated files. tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: BasePartialProcessor hides exceptions by default

1 participant