Fix run.taskIdentifier being reported as "unknown" for batch triggers#2974
Fix run.taskIdentifier being reported as "unknown" for batch triggers#2974bharathkumar39293 wants to merge 9 commits intotriggerdotdev:mainfrom
Conversation
🦋 Changeset detectedLatest commit: 7f138d1 The changes in this PR will be included in the next version bump. This PR includes changesets to release 28 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
WalkthroughThe PR threads a new Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Repository UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
🧰 Additional context used🧠 Learnings (11)📓 Common learnings📚 Learning: 2025-11-27T16:27:35.304ZApplied to files:
📚 Learning: 2025-11-27T16:27:35.304ZApplied to files:
📚 Learning: 2025-11-27T16:27:35.304ZApplied to files:
📚 Learning: 2025-11-27T16:27:35.304ZApplied to files:
📚 Learning: 2026-01-15T11:50:06.067ZApplied to files:
📚 Learning: 2025-11-27T16:27:35.304ZApplied to files:
📚 Learning: 2025-11-27T16:27:35.304ZApplied to files:
📚 Learning: 2025-11-27T16:27:35.304ZApplied to files:
📚 Learning: 2025-11-27T16:27:35.304ZApplied to files:
📚 Learning: 2025-11-27T16:27:35.304ZApplied to files:
⏰ 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). (27)
🔇 Additional comments (2)
✏️ Tip: You can disable this entire section by setting 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. Comment |
Review CompleteYour review story is ready! Comment !reviewfast on this PR to re-generate the story. |
|
@ericallam I've updated the PR with the requested changes:
|
| include: { | ||
| completedByTaskRun: { | ||
| select: { | ||
| taskIdentifier: true, | ||
| }, | ||
| }, | ||
| }, |
There was a problem hiding this comment.
🚩 Additional Prisma JOINs added to multiple hot query paths
This PR adds include: { completedByTaskRun: { select: { taskIdentifier: true } } } to four separate query paths: getLatestExecutionSnapshot (line 182-190), getExecutionSnapshotCompletedWaitpoints (line 210-218), fetchWaitpointsInChunks (line 161-167), and the ExecutionSnapshotWithCheckAndWaitpoints type (line 34-42). Each of these now performs an extra JOIN to the TaskRun table for every waitpoint. For runs with many waitpoints (e.g., large batches of 1000), this adds 1000 JOINs. The completedByTaskRunId column has a @unique constraint, so the JOIN should be efficient (index lookup), but it's worth monitoring query performance for large batch scenarios.
Was this helpful? React with 👍 or 👎 to provide feedback.
Closes #2942
This PR fixes an issue where run.taskIdentifier was reported as "unknown" when using batch.triggerAndWait / batch.triggerByTaskAndWait.
The root cause was that taskIdentifier was not propagated from the platform to the worker via the
CompletedWaitpoint
, causing the runtime to fall back to "unknown".
Changes
Schema
Added taskIdentifier to the
CompletedWaitpoint
schema (
packages/core/src/v3/schemas/runEngine.ts
)
Platform
Updated
ExecutionSnapshotSystem
to:
Select taskIdentifier from the database
Map it onto the
CompletedWaitpoint
sent to the worker (
internal-packages/run-engine/src/engine/systems/executionSnapshotSystem.ts
)
Worker
Updated
SharedRuntimeManager
to use waitpoint.completedByTaskRun.taskIdentifier when constructing the execution result (
packages/core/src/v3/runtime/sharedRuntimeManager.ts
)
Added a backward-compatible fallback to "unknown" for legacy runs
Verification
Unit Tests
Added
packages/core/src/v3/runtime/sharedRuntimeManager.test.ts
covering:
Correct propagation of taskIdentifier when present
Graceful fallback to "unknown" when missing
All tests are passing.