Skip to content

Commit fc0adfc

Browse files
committed
fix(cloudflare): Also skip cf: prefixed DOs
1 parent a5f43c0 commit fc0adfc

3 files changed

Lines changed: 21 additions & 1 deletion

File tree

packages/cloudflare/src/utils/internalStorageKey.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,14 @@ export function targetsCloudflareInternalKey(key: string | undefined, allowlist?
2020

2121
// Framework-managed KV namespaces:
2222
// - `cf_` — agents / ai-chat internal state (mirrors the internal SQL table convention)
23+
// - `cf:` — agents chat-recovery entries (`cf:chat-recovery:*`, `cf:chat:*`); the same reserved
24+
// `cf` namespace, but colon-separated instead of underscore-separated
2325
// - `__ps_` — partyserver internals (e.g. `__ps_name`)
2426
// - `/` — MCP OAuth client state (`/<clientName>/<serverId>/{token,client_info,state,...}`),
2527
// read on every MCP tool call. User keys on an Agent rarely use a leading slash; if one does,
2628
// the allowlist opts it back in.
27-
const isFrameworkKey = key.startsWith('cf_') || key.startsWith('__ps_') || key.startsWith('/');
29+
const isFrameworkKey =
30+
key.startsWith('cf_') || key.startsWith('cf:') || key.startsWith('__ps_') || key.startsWith('/');
2831
if (!isFrameworkKey) {
2932
return false;
3033
}

packages/cloudflare/test/instrumentDurableObjectStorage.test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,17 @@ describe('instrumentDurableObjectStorage', () => {
343343
expect(startSpanSpy).not.toHaveBeenCalled();
344344
});
345345

346+
it('does not create a span for cf:-prefixed chat-recovery keys', async () => {
347+
const startSpanSpy = vi.spyOn(sentryCore, 'startSpan');
348+
const instrumented = instrumentDurableObjectStorage(createMockStorage());
349+
350+
await instrumented.put('cf:chat-recovery:progress', 1);
351+
await instrumented.get('cf:chat-recovery:incident:abc');
352+
await instrumented.list({ prefix: 'cf:chat-recovery:incident:' });
353+
354+
expect(startSpanSpy).not.toHaveBeenCalled();
355+
});
356+
346357
it('does not create a span for a cf_-prefixed put with object entries', async () => {
347358
const startSpanSpy = vi.spyOn(sentryCore, 'startSpan');
348359
const instrumented = instrumentDurableObjectStorage(createMockStorage());

packages/cloudflare/test/utils/internalStorageKey.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ describe('targetsCloudflareInternalKey', () => {
77
expect(targetsCloudflareInternalKey('cf_mcp_servers')).toBe(true);
88
});
99

10+
it('matches cf:-prefixed keys (agents chat-recovery namespace)', () => {
11+
expect(targetsCloudflareInternalKey('cf:chat-recovery:incident:abc')).toBe(true);
12+
expect(targetsCloudflareInternalKey('cf:chat-recovery:progress')).toBe(true);
13+
expect(targetsCloudflareInternalKey('cf:chat:recovering')).toBe(true);
14+
});
15+
1016
it('matches __ps_-prefixed keys', () => {
1117
expect(targetsCloudflareInternalKey('__ps_name')).toBe(true);
1218
});

0 commit comments

Comments
 (0)