test(cloudflare): Add Flue E2E test that deploys a real Worker and sends to Sentry - #24816
Conversation
size-limit report 📦
|
c1a82e2 to
360c698
Compare
RulaKhaled
left a comment
There was a problem hiding this comment.
looks good. one thing: the PR description is stale, the last paragraph says the attribute checks, the manual-span nesting and the dataloader check go away pending fetchSpanAttributes from #24514. that helper is on develop already and all three are asserted in the tests here, so worth updating before the squash
| { | ||
| "$schema": "./node_modules/wrangler/config-schema.json", | ||
| // Placeholder only: every test run deploys under a unique name, see global-setup.ts. | ||
| "name": "cloudflare-flue", |
There was a problem hiding this comment.
l: rename the placeholder to match the directory
360c698 to
2fff275
Compare
…nds to Sentry cloudflare-flue-send-to-sentry deploys a Flue agent as a real Worker, runs real model turns, and polls the E2E project through the sentry CLI. It is optional, like the other apps that need the Cloudflare secrets. It replaces cloudflare-flue, which ran the same agent locally behind the event proxy. Flue runs the turn from a Durable Object alarm, and the SDK starts a new trace for each alarm, so the test cannot send the trace id with the request. It reads the conversation id from Flue and finds the trace by `gen_ai.conversation.id` through the events API (`findTraceIdOfSpan`), because `sentry span list` returns no trace id for a project search. `sentry api` caches GET responses and has no `--fresh` flag, so the CLI now runs with `SENTRY_NO_CACHE=1`. Without it, every poll got the first empty answer again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… and sends to Sentry Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… and sends to Sentry Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… and sends to Sentry Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… and sends to Sentry Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… and sends to Sentry Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… and sends to Sentry Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
d6498f5 to
dcb678c
Compare
| run: ({ data }) => | ||
| Sentry.startSpan({ name: 'resolve-weather', attributes: { 'weather.source': 'static-table' } }, () => { | ||
| return `It is 21 degrees and sunny in ${city}.`; | ||
| return `It is 21 degrees and sunny in ${data.city}.`; |
There was a problem hiding this comment.
Bug: The run callback for the get_weather tool incorrectly destructures its input as ({ data }) instead of ({ city }), which will cause a TypeError at runtime.
Severity: HIGH
Suggested Fix
Change the parameter destructuring in the run callback from ({ data }) => ... data.city to ({ city }) => ... city. This aligns the function signature with the tool's input definition and prevents the runtime error.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location:
dev-packages/e2e-tests/test-applications/cloudflare-flue-send-to-sentry/src/agents/hello.ts#L20-L22
Potential issue: The `run` callback for the `get_weather` tool in `hello.ts`
destructures its input as `({ data })` and then accesses `data.city`. However, the
tool's input schema is defined as `v.object({ city: v.string() })`, and the runtime
passes the arguments directly, not nested within a `data` object. This mismatch will
cause the `data` parameter to be `undefined`, leading to a `TypeError` when `data.city`
is accessed. This will cause the E2E tests, which explicitly invoke this tool, to fail.
Did we get this right? 👍 / 👎 to inform future reviews.
Adds
cloudflare-flue-send-to-sentry. It deploys a Flue agent as a real Worker, runs real model turns through OpenRouter, and checks through thesentryCLI that thegen_aispans and a tool error arrive in Sentry. It replacescloudflare-flue, which ran the same agent locally behind the event proxy. The app has noinstrument()call, so it still proves that@sentry/cloudflare/viteregisters the Flue instrumentation at build time.To protect unwanted calls from outside anyone from our public workers a
E2E_TEST_WORKER_TOKENhas been added which is automatically added to each deployment (see #24816 (comment))Flue runs the turn from a Durable Object alarm, and the SDK starts a new trace for each alarm. So the test cannot send the trace id with its request, as the other send-to-sentry tests do. It reads the conversation id back from Flue and finds the trace by
gen_ai.conversation.idthrough the events API (newfindTraceIdOfSpan), becausesentry span listreturns no trace id for a project search.The CLI now runs with
SENTRY_NO_CACHE=1.sentry apicaches GET responses and has no--freshflag, so without it every poll got the first empty answer again.Checks that go away with
cloudflare-flueon Cloudflare: the span attributes (origin, provider, token usage), the manual span under the tool span, and the dataloader span that orchestrion adds at build time.node-fluestill has them on Node. The CLI trace view drops span attributes, so the attribute checks needfetchSpanAttributesfrom #24514 first.🤖 Generated with Claude Code