@@ -14,7 +14,6 @@ import { parsePacketAsJson } from "@trigger.dev/core/v3/utils/ioSerialization";
1414import { BatchId } from "@trigger.dev/core/v3/isomorphic" ;
1515import { getUserProvidedIdempotencyKey } from "@trigger.dev/core/v3/serverOnly" ;
1616import type { Prisma , TaskRunAttemptStatus , TaskRunStatus } from "@trigger.dev/database" ;
17- import type { RbacAbility } from "@trigger.dev/rbac" ;
1817import assertNever from "assert-never" ;
1918import type { API_VERSIONS , RunStatusUnspecifiedApiVersion } from "~/api/versions" ;
2019import { CURRENT_API_VERSION } from "~/api/versions" ;
@@ -84,24 +83,6 @@ type CommonRelatedRunWithVersion = CommonRelatedRun & {
8483// ReturnType<typeof findRun>) so findRun can return a synthesised buffered
8584// run without the type becoming self-referential. Exported so the
8685// buffer-synthesis helper below can match this shape under unit test.
87- function canReadRelatedRun (
88- ability : RbacAbility | undefined ,
89- run : CommonRelatedRunWithVersion
90- ) : boolean {
91- if ( ! ability ) return true ;
92-
93- const resources = [
94- { type : "runs" , id : run . friendlyId } ,
95- { type : "tasks" , id : run . taskIdentifier } ,
96- ...run . runTags . map ( ( tag ) => ( { type : "tags" , id : tag } ) ) ,
97- ] ;
98- if ( run . batch ?. friendlyId ) {
99- resources . push ( { type : "batch" , id : run . batch . friendlyId } ) ;
100- }
101-
102- return ability . can ( "read" , resources ) ;
103- }
104-
10586export type FoundRun = CommonRelatedRunWithVersion & {
10687 traceId : string ;
10788 payload : string ;
@@ -231,7 +212,7 @@ export class ApiRetrieveRunPresenter {
231212 return synthesiseFoundRunFromBuffer ( buffered ) ;
232213 }
233214
234- public async call ( taskRun : FoundRun , env : AuthenticatedEnvironment , ability ?: RbacAbility ) {
215+ public async call ( taskRun : FoundRun , env : AuthenticatedEnvironment ) {
235216 return startSpanWithEnv ( tracer , "ApiRetrieveRunPresenter.call" , env , async ( ) => {
236217 let $payload : any ;
237218 let $payloadPresignedUrl : string | undefined ;
@@ -308,19 +289,19 @@ export class ApiRetrieveRunPresenter {
308289 attemptCount :
309290 taskRun . engine === "V1" ? taskRun . attempts . length : ( taskRun . attemptNumber ?? 0 ) ,
310291 attempts : [ ] ,
292+ // Related runs are an embedded projection of the authorized run, not independent reads.
293+ // Preserve the established response shape for run-scoped credentials.
311294 relatedRuns : {
312- root :
313- taskRun . rootTaskRun && canReadRelatedRun ( ability , taskRun . rootTaskRun )
314- ? await createCommonRunStructure ( taskRun . rootTaskRun , this . apiVersion )
315- : undefined ,
316- parent :
317- taskRun . parentTaskRun && canReadRelatedRun ( ability , taskRun . parentTaskRun )
318- ? await createCommonRunStructure ( taskRun . parentTaskRun , this . apiVersion )
319- : undefined ,
295+ root : taskRun . rootTaskRun
296+ ? await createCommonRunStructure ( taskRun . rootTaskRun , this . apiVersion )
297+ : undefined ,
298+ parent : taskRun . parentTaskRun
299+ ? await createCommonRunStructure ( taskRun . parentTaskRun , this . apiVersion )
300+ : undefined ,
320301 children : await Promise . all (
321- taskRun . childRuns
322- . filter ( ( run ) => canReadRelatedRun ( ability , run ) )
323- . map ( async ( run ) => await createCommonRunStructure ( run , this . apiVersion ) )
302+ taskRun . childRuns . map (
303+ async ( run ) => await createCommonRunStructure ( run , this . apiVersion )
304+ )
324305 ) ,
325306 } ,
326307 } ;
0 commit comments