Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

fix(desktop): drop the vetted markers from the read-plane banner

Alfredo Lopez56389ae53fce
diff --git a/desktop-app/ui/src/components/__tests__/gfsPreviewReadErrors.test.tsx b/desktop-app/ui/src/components/__tests__/gfsPreviewReadErrors.test.tsx
index 436cc36b1..aa9d0d3ba 100644
--- a/desktop-app/ui/src/components/__tests__/gfsPreviewReadErrors.test.tsx
+++ b/desktop-app/ui/src/components/__tests__/gfsPreviewReadErrors.test.tsx
@@ -120,9 +120,14 @@ describe('GFS preview read failures', () => {
// the wrapper naming our process boundary does not. Without this case the
// assertions above would also pass on a presenter that answered
// "Too many file requests" to everything.
+ //
+ // Matched whole, not as a substring. An un-anchored matcher passes with
+ // the vetted `httpStatus=403` marker still on screen, which is how the
+ // banner shipped one piece of our plumbing in place of another.
await waitFor(() =>
- expect(screen.getByText(/403 Forbidden: read access was revoked/)).toBeTruthy()
+ expect(screen.getByText('403 Forbidden: read access was revoked')).toBeTruthy()
)
+ expect(screen.queryByText(/httpStatus=/)).toBeNull()
expect(screen.queryByText(/Error invoking remote method/)).toBeNull()
}
)
diff --git a/desktop-app/ui/src/lib/__tests__/gfsGrantErrors.test.ts b/desktop-app/ui/src/lib/__tests__/gfsGrantErrors.test.ts
index df80b57e5..bd71a4819 100644
--- a/desktop-app/ui/src/lib/__tests__/gfsGrantErrors.test.ts
+++ b/desktop-app/ui/src/lib/__tests__/gfsGrantErrors.test.ts
@@ -193,6 +193,21 @@ describe('describeGfsGrantError', () => {
severity: 'error',
})
})
+
+ it('drops the vetted markers from the grant banner too', () => {
+ // `surfaceGfsGrantError` wraps the grant methods as well as the read ones,
+ // so the same marker reaches this plane's pass-through branch. Verbatim
+ // means the server's verdict, not our plumbing appended to it.
+ const raw = '409 Conflict: grant_version_stale httpStatus=409'
+
+ // Liveness witness: the marker is present and readable before the strip.
+ expect(parseHttpStatus(raw)).toBe(409)
+ expect(describeGfsGrantError(new Error(raw))).toEqual({
+ code: null,
+ message: '409 Conflict: grant_version_stale',
+ severity: 'error',
+ })
+ })
})
/**
@@ -251,6 +266,51 @@ describe('describeGfsReadError', () => {
expect(presented.message).toBe('503 Service Unavailable: upstream_unreachable')
})
+ it('drops the vetted markers from the banner after reading them', () => {
+ // The markers are plumbing between our two processes, exactly like the IPC
+ // wrapper above. Swapping one for the other in front of the user is not a
+ // fix, and a user told "read access was revoked httpStatus=403" is being
+ // shown the mechanism instead of the reason.
+ const raw =
+ "Error invoking remote method 'gfs:downloadPreview': Error: 403 Forbidden: " +
+ 'read access was revoked httpStatus=403'
+
+ // Liveness witness, and the reason the strip runs LAST: the marker is
+ // present and readable on the way in. A strip applied before classifying
+ // would leave this at null, which is the misclassification this module
+ // exists to prevent.
+ expect(parseHttpStatus(raw)).toBe(403)
+ expect(describeGfsReadError(new Error(raw)).message).toBe(
+ '403 Forbidden: read access was revoked'
+ )
+ })
+
+ it('drops both markers when the server sent a window with a non-429 verdict', () => {
+ // The builder appends them in a fixed order — [invalidIndexes] [httpStatus]
+ // [retryAfterSeconds] — so removing them takes the reverse. One pass that
+ // stopped at `retryAfterSeconds` would leave `httpStatus=503` on screen.
+ const raw = '503 Service Unavailable: upstream_unreachable httpStatus=503 retryAfterSeconds=30'
+
+ expect(parseHttpStatus(raw)).toBe(503)
+ expect(parseRetryAfterSeconds(raw)).toBe(30)
+ expect(describeGfsReadError(new Error(raw)).message).toBe(
+ '503 Service Unavailable: upstream_unreachable'
+ )
+ })
+
+ it("leaves a lookalike the server's own body carried", () => {
+ // Only the suffix position is ours. A token ahead of it is the server's
+ // text, and `surfaceGfsGrantError` already stripped the ones that could
+ // have been mistaken for a verdict — so editing this one would be the
+ // renderer rewriting a diagnostic it does not own.
+ const raw = '500 Internal Server Error: {"upstream":"httpStatus=429"} httpStatus=500'
+
+ expect(parseHttpStatus(raw)).toBe(500)
+ expect(describeGfsReadError(new Error(raw)).message).toBe(
+ '500 Internal Server Error: {"upstream":"httpStatus=429"}'
+ )
+ })
+
it('reads a retry window only from its own field', () => {
// A pattern that skips non-digits binds to the next number ANYWHERE in the
// message, so a null window next to an unrelated number yielded that
diff --git a/desktop-app/ui/src/lib/gfsGrantErrors.ts b/desktop-app/ui/src/lib/gfsGrantErrors.ts
index f113b10bc..ca5b5be7d 100644
--- a/desktop-app/ui/src/lib/gfsGrantErrors.ts
+++ b/desktop-app/ui/src/lib/gfsGrantErrors.ts
@@ -43,6 +43,31 @@ export function stripIpcWrapper(message: string): string {
return message.replace(IPC_WRAPPER_PREFIX, '')
}
+/**
+ * Drop the markers the main process appends for the renderer's own use.
+ *
+ * `surfaceGfsGrantError` puts `httpStatus=` and `retryAfterSeconds=` at the end
+ * of the message so the classifiers below can read a verdict that prose cannot
+ * carry. They are plumbing between our two processes, exactly like the IPC
+ * wrapper above, and a user told "read access was revoked httpStatus=403" is
+ * being shown the mechanism instead of the reason. Removing one piece of
+ * plumbing from the banner while adding another is not a fix.
+ *
+ * Anchored to the end and applied in the reverse of the order the builder
+ * appends them, so this removes only what that builder wrote. A copy carried by
+ * the server's own body sits ahead of that position and is left intact: it is
+ * the server's text, and `surfaceGfsGrantError` has already stripped the ones
+ * that could have been mistaken for a verdict.
+ *
+ * Strip only AFTER classifying. `isRateLimited`, `parseHttpStatus` and
+ * `parseRetryAfterSeconds` all read these markers; a message cleaned first is a
+ * message that can no longer be classified, which is the incident this module
+ * exists to prevent.
+ */
+export function stripVettedMarkers(message: string): string {
+ return message.replace(/\s+retryAfterSeconds=\d+$/, '').replace(/\s+httpStatus=\d{3}$/, '')
+}
+
function rawMessage(error: unknown): string {
return error instanceof Error ? error.message : String(error ?? '')
}
@@ -193,7 +218,7 @@ export function describeGfsReadError(error: unknown): GfsGrantErrorPresentation
return {
code: null,
- message: stripIpcWrapper(raw) || 'The file request failed.',
+ message: stripVettedMarkers(stripIpcWrapper(raw)) || 'The file request failed.',
severity: 'error',
}
}
@@ -218,5 +243,9 @@ export function describeGfsGrantError(error: unknown): GfsGrantErrorPresentation
return { code, message, severity: code === 'manage_acl_required' ? 'quiet' : 'error' }
}
- return { code: null, message: raw || 'The permission change failed.', severity: 'error' }
+ return {
+ code: null,
+ message: stripVettedMarkers(raw) || 'The permission change failed.',
+ severity: 'error',
+ }
}