Skip to content

Improve batch worker error log serialization and test assertions#591

Draft
cmraible wants to merge 3 commits intomainfrom
improve-error-logging
Draft

Improve batch worker error log serialization and test assertions#591
cmraible wants to merge 3 commits intomainfrom
improve-error-logging

Conversation

@cmraible
Copy link
Collaborator

Summary

  • Updated batch worker error logging to use Pino's err field so error message and stack are serialized in structured logs
  • Added a reusable in-memory log capture utility for tests at test/utils/log-capture.ts
  • Migrated batch worker unit tests to assert emitted log output instead of logger spy calls, including error serialization checks

@coderabbitai
Copy link

coderabbitai bot commented Feb 26, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch improve-error-logging

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

cmraible added 2 commits March 2, 2026 16:04
Pino only auto-serializes errors (message, stack) on the `err` key.
Using `error` silently loses structured error data in production logs.
@cmraible cmraible force-pushed the improve-error-logging branch from b906863 to ceb2872 Compare March 3, 2026 00:05
@ErisDS
Copy link
Member

ErisDS commented Mar 3, 2026

🤖 Velo CI Failure Analysis

Classification: 🟠 SOFT FAIL

  • Workflow: CI
  • Failed Step: Lint & Test
  • Run: View failed run
    What failed: Test assertion failure in UserSignatureService.test.ts
    Why: The root cause is a test assertion failure in the UserSignatureService.test.ts file. This is a code issue, as the test is failing due to an issue in the application code, not an infrastructure problem.
    Action:
    The author should investigate the failing test case and fix the underlying issue in the UserSignatureService implementation.

@cmraible cmraible force-pushed the improve-error-logging branch from ceb2872 to 52ca8c9 Compare March 3, 2026 00:11
Comment on lines +45 to +48
const errorMessage = error instanceof Error ? error.message : String(error);
logger.error({
event: 'EventPublishFailed',
error: errorMessage,
err: errorMessage,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

we should log the whole error here, not just the error message.

Comment on lines +108 to +113
messageId: message.id,
messageData: this.getMessageData(message),
error
err: error
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Let's rename error to err, so we can just pass it in the object as-is

Rename `error` to `err` in all logger calls so Pino's error serializer
properly extracts message and stack trace in structured logs.
@cmraible cmraible force-pushed the improve-error-logging branch from 52ca8c9 to af99306 Compare March 3, 2026 00:51
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.

2 participants