Skip to content

Commit 90ae19b

Browse files
committed
improvement(logs): name the projection warning's read/write phase explicitly
1 parent 01384b5 commit 90ae19b

2 files changed

Lines changed: 13 additions & 10 deletions

File tree

‎apps/sim/lib/logs/execution/trace-secret-projection.test.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,7 +1022,7 @@ describe('projectTraceSpansForSecrets', () => {
10221022
executionId: 'execution-1',
10231023
workflowId: 'workflow-1',
10241024
workspaceId: 'workspace-1',
1025-
readOnly: false,
1025+
phase: 'write',
10261026
spanId: 'span-1',
10271027
spanType: 'function',
10281028
field: 'output',
@@ -1094,7 +1094,7 @@ describe('projectTraceSpansForSecrets whole-trace content budget', () => {
10941094
'Trace content exceeded the projection budget; withholding the remaining spans',
10951095
expect.objectContaining({
10961096
executionId: 'execution-1',
1097-
readOnly: true,
1097+
phase: 'read',
10981098
retainedSpanCount: 2,
10991099
withheldSpanCount: 2,
11001100
})
@@ -1123,7 +1123,7 @@ describe('projectTraceSpansForSecrets whole-trace content budget', () => {
11231123
expect(projected[0].contentWithheld).toBe(true)
11241124
expect(warnMock).toHaveBeenCalledWith(
11251125
'Trace secret projection failed; retaining structural spans only',
1126-
expect.objectContaining({ executionId: 'execution-1', readOnly: true })
1126+
expect.objectContaining({ executionId: 'execution-1', phase: 'read' })
11271127
)
11281128
})
11291129

‎apps/sim/lib/logs/execution/trace-secret-projection.ts‎

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -139,25 +139,28 @@ class TraceSecretProjectionError extends Error {
139139
*/
140140
class TraceContentBudgetError extends TraceSecretProjectionError {}
141141

142-
/** Identifies the run behind a projection warning; every field is a stored id or a mode flag. */
142+
/**
143+
* Identifies the run behind a projection warning. `phase` says whether the run was being written
144+
* to the log or a stored log was being read for display.
145+
*/
143146
interface ProjectionLogDetails {
144147
executionId?: string
145148
workflowId?: string
146149
workspaceId?: string
147-
readOnly: boolean
150+
phase: 'read' | 'write'
148151
}
149152

150153
function projectionLogDetails(
151154
store: LargeValueStoreContext,
152-
readOnly: boolean
155+
phase: ProjectionLogDetails['phase']
153156
): ProjectionLogDetails {
154157
return {
155158
...filterUndefined({
156159
executionId: store.executionId,
157160
workflowId: store.workflowId,
158161
workspaceId: store.workspaceId,
159162
}),
160-
readOnly,
163+
phase,
161164
}
162165
}
163166

@@ -203,7 +206,7 @@ function createProjectionContext(
203206
sourceLargeValueBytes: 0,
204207
storedLargeValueBytes: 0,
205208
storedLargeValueCount: 0,
206-
logDetails: projectionLogDetails(store, !allowLargeValueWrites),
209+
logDetails: projectionLogDetails(store, allowLargeValueWrites ? 'write' : 'read'),
207210
}
208211
}
209212

@@ -1647,7 +1650,7 @@ export async function enforceTraceSpanSecretInvariant(
16471650
return traceSpans
16481651
} catch (error) {
16491652
logger.warn('Trace secret invariant failed; retaining structural spans only', {
1650-
...projectionLogDetails(options.store, false),
1653+
...projectionLogDetails(options.store, 'write'),
16511654
failure: describeProjectionFailure(error),
16521655
})
16531656
return structuralOnlyTraceSpans(traceSpans)
@@ -1667,7 +1670,7 @@ export async function projectTraceSpansForSecrets(
16671670
}
16681671

16691672
const allowLargeValueWrites = options.allowLargeValueWrites !== false
1670-
const logDetails = projectionLogDetails(options.store, !allowLargeValueWrites)
1673+
const logDetails = projectionLogDetails(options.store, allowLargeValueWrites ? 'write' : 'read')
16711674
try {
16721675
const matcher = createResolvedSecretMatcher(options.registry.getActiveMatches(), {
16731676
preserveNamedProvenanceLabels: true,

0 commit comments

Comments
 (0)