(ctx context.Context, id *call.ID)
| 60 | } |
| 61 | |
| 62 | func resultCallRefFromIDInput(ctx context.Context, id *call.ID) (*ResultCallRef, error) { |
| 63 | if id == nil { |
| 64 | return nil, fmt.Errorf("nil ID input") |
| 65 | } |
| 66 | if !id.IsHandle() { |
| 67 | frame, err := resultCallFromRecipeIDInput(ctx, id) |
| 68 | if err != nil { |
| 69 | return nil, err |
| 70 | } |
| 71 | if frame == nil { |
| 72 | return nil, nil |
| 73 | } |
| 74 | return &ResultCallRef{Call: frame}, nil |
| 75 | } |
| 76 | clientMetadata, err := engine.ClientMetadataFromContext(ctx) |
| 77 | if err != nil { |
| 78 | return nil, fmt.Errorf("resolve ID input %q: current client metadata: %w", idInputDebugString(id), err) |
| 79 | } |
| 80 | if clientMetadata.SessionID == "" { |
| 81 | return nil, fmt.Errorf("resolve ID input %q: empty session ID", idInputDebugString(id)) |
| 82 | } |
| 83 | cache, err := EngineCache(ctx) |
| 84 | if err != nil { |
| 85 | return nil, fmt.Errorf("resolve ID input %q: current dagql cache: %w", idInputDebugString(id), err) |
| 86 | } |
| 87 | shared, _, _, err := cache.sharedResultByResultID( |
| 88 | ctx, |
| 89 | clientMetadata.SessionID, |
| 90 | sharedResultID(id.EngineResultID()), |
| 91 | sharedResultLookupCanonicalEquivalent, |
| 92 | ) |
| 93 | if err != nil { |
| 94 | return nil, fmt.Errorf("resolve ID input %q: %w", idInputDebugString(id), err) |
| 95 | } |
| 96 | frame := shared.loadResultCall() |
| 97 | if frame == nil { |
| 98 | return nil, fmt.Errorf("resolve ID input %q: missing result call frame", idInputDebugString(id)) |
| 99 | } |
| 100 | if frame.Type != nil && frame.Type.NamedType == "Query" { |
| 101 | return nil, nil |
| 102 | } |
| 103 | return &ResultCallRef{ResultID: uint64(shared.id), shared: shared}, nil |
| 104 | } |
| 105 | |
| 106 | func resultCallFromRecipeIDInput(ctx context.Context, id *call.ID) (*ResultCall, error) { |
| 107 | if id == nil { |
no test coverage detected