Repository navigation
fix: transformBatch reporting metrics issue - #4559
Conversation
Summary by CodeRabbit
WalkthroughAdds generation and propagation of messageId/eventName/eventType for transformed events by importing generateUUID, introducing generateNewMetadata, and enhancing tracking of output/input message IDs (including on error) when assembling output metadata. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Caller
participant UserTransform as userTransform
participant GenMeta as generateNewMetadata
participant GenUUID as generateUUID
Caller->>UserTransform: submit input events
Note right of UserTransform: iterate transformed events
alt metadata missing or no messageId
UserTransform->>GenMeta: request metadata (ev, firstInput)
GenMeta->>GenUUID: generate messageId
GenUUID-->>GenMeta: messageId
GenMeta-->>UserTransform: metadata with messageId & eventName/type
else metadata present with messageId
UserTransform-->>UserTransform: retain ev.metadata
end
UserTransform-->>UserTransform: collect output messageIds (ev.metadata.messageId / messageIds)
alt ev.error present
UserTransform-->>UserTransform: include input messageIds from commonMetadata
end
UserTransform-->>Caller: return events with ensured metadata
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Suggestions:
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 💡 Knowledge Base configuration:
You can enable these sources in your CodeRabbit configuration. 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
Status, Documentation and Community
|
|
Allure Test reports for this run are available at:
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #4559 +/- ##
===========================================
- Coverage 91.78% 91.78% -0.01%
===========================================
Files 642 642
Lines 33931 33941 +10
Branches 8032 8035 +3
===========================================
+ Hits 31145 31152 +7
- Misses 2556 2559 +3
Partials 230 230 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Allure Test reports for this run are available at:
|
1 similar comment
|
Allure Test reports for this run are available at:
|
|
Allure Test reports for this run are available at:
|
2 similar comments
|
Allure Test reports for this run are available at:
|
|
Allure Test reports for this run are available at:
|
|
Allure Test reports for this run are available at:
|
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/services/userTransform.ts (1)
115-122: Don’t treat any error event as “global failure”; gate adding all input IDs to output setCurrently, when ev.error is present without messageId(s), you add every input messageId to messageIdsInOutputSet. If UT returns a mixed result (some successes and a separate error event without metadata), this will mask legitimately filtered inputs. Gate this behavior to the “single error event with no metadata” case.
Apply this diff:
- } else if (ev.error) { - commonMetadata.messageIds.forEach((id) => messageIdsInOutputSet.add(id)); + } else if (ev.error && destTransformedEvents.length === 1 && isEmpty(ev.metadata)) { + // When UT returns exactly one error event (no metadata), treat it as a batch-level failure + commonMetadata.messageIds.forEach((id) => messageIdsInOutputSet.add(id));I also recommend adding tests to cover:
- Single batch-level error event with no metadata → no filtered events emitted.
- Mixed outputs: some success events with proper metadata + one error event with no metadata → only inputs without outputs are filtered; successes are preserved.
I can draft these tests if helpful.
🧹 Nitpick comments (1)
src/services/userTransform.ts (1)
143-147: LGTM on ensuring metadata.messageId for new/malformed metadataThis correctly ensures output events carry a messageId when ev.metadata is empty or missing one. With the revised generateNewMetadata, this will also preserve ev.metadata fields when present and avoid copying unrelated first-event messageIds into new events.
Optional: For readability, consider using optional chaining in the condition:
- Replace !ev.metadata.messageId with !ev.metadata?.messageId
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
src/services/userTransform.ts(4 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/services/userTransform.ts (1)
src/types/userTransformation.ts (1)
UserTransformationResponse(14-18)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
- GitHub Check: Build Transformer Docker Image - PR / Build Transformer Docker Image AMD64
- GitHub Check: Build Transformer Docker Image - PR / Build Transformer Docker Image ARM64
- GitHub Check: Build User Transformer Docker Image - PR / Build Transformer Docker Image AMD64
- GitHub Check: Build User Transformer Docker Image - PR / Build Transformer Docker Image ARM64
- GitHub Check: Code Coverage
- GitHub Check: test_and_publish
🔇 Additional comments (1)
src/services/userTransform.ts (1)
4-4: Confirmuuiddependency or switch to native crypto.randomUUIDIt looks like no
package.jsonwas detected in the workspace, so we can’t automatically verify that theuuidpackage is declared. Please check your project’s manifest and either adduuidtodependenciesor drop the external dependency in favor of Node’s built-in API.• Ensure you have a
package.json(at the repo root or in the relevant workspace) with:
"uuid": "<version>"underdependencies
• If you’d rather avoid a new dependency, replace:- import { v4 as uuidv4 } from 'uuid'; + import { randomUUID } from 'crypto';and update all
uuidv4()calls torandomUUID().
• Verify your target Node.js version supportscrypto.randomUUID(Node v14.17+).
|
Allure Test reports for this run are available at:
|
|
Allure Test reports for this run are available at:
|
|
Allure Test reports for this run are available at:
|
|
Allure Test reports for this run are available at:
|
35047e9 to
8089082
Compare
|
Allure Test reports for this run are available at:
|
|



What are the changes introduced in this PR?
This PR fixes the issue with reporting metrics generated when transformBatch is used.
What is the related Linear task?
Resolves OBS-828
Please explain the objectives of your changes below
Currently, there are two issues with the UT response when transformBatch is used:
Any changes to existing capabilities/behaviour, mention the reason & what are the changes ?
N/A
Any new dependencies introduced with this change?
N/A
Any new generic utility introduced or modified. Please explain the changes.
N/A
Any technical or performance related pointers to consider with the change?
N/A
@coderabbitai review
Developer checklist
My code follows the style guidelines of this project
No breaking changes are being introduced.
All related docs linked with the PR?
All changes manually tested?
Any documentation changes needed with this change?
Is the PR limited to 10 file changes?
Is the PR limited to one linear task?
Are relevant unit and component test-cases added in new readability format?
Reviewer checklist
Is the type of change in the PR title appropriate as per the changes?
Verified that there are no credentials or confidential data exposed with the changes.