Skip to content
This repository was archived by the owner on Oct 23, 2026. It is now read-only.

feat(local): inject Spotlight as a Wrangler Worker binding - #1351

Merged
MathurAditya724 merged 5 commits into
mainfrom
cursor/inject-wrangler-spotlight-binding-27d6
Aug 3, 2026
Merged

MathurAditya724 merged 5 commits into
mainfrom
cursor/inject-wrangler-spotlight-binding-27d6

Conversation

@MathurAditya724

Copy link
Copy Markdown
Member

Wrangler does not expose inherited process environment variables to Worker code, so the SENTRY_SPOTLIGHT value set by local run never reached @sentry/cloudflare. Users had to hard-code spotlight: true in their SDK config.

Detect Wrangler dev commands in Workers projects and add the ephemeral --var SENTRY_SPOTLIGHT: binding. This works for direct/npx commands, package-manager scripts, auto-detected shell scripts, custom config paths and verify mode; explicit user bindings remain untouched. No wrangler config or .dev.vars files are modified.

Wrangler does not expose inherited process environment variables to
Worker code, so the SENTRY_SPOTLIGHT value set by local run never
reached @sentry/cloudflare. Users had to hard-code spotlight: true in
their SDK config.

Detect Wrangler dev commands in Workers projects and add the ephemeral
--var SENTRY_SPOTLIGHT:<url> binding. This works for direct/npx commands,
package-manager scripts, auto-detected shell scripts, custom config
paths and verify mode; explicit user bindings remain untouched. No
wrangler config or .dev.vars files are modified.

Co-authored-by: Aditya Mathur <MathurAditya724@users.noreply.github.com>
@github-actions

github-actions Bot commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-08-03 19:27 UTC

Comment thread packages/cli/src/lib/wrangler.ts Resolved

@BYK BYK left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shell-wrapped dev scripts were augmented by appending --var to the end
of the entire script. For commands such as 'wrangler dev && echo done',
that passed the binding to echo instead of Wrangler while still claiming
injection succeeded.

Scan from the wrangler dev invocation to the next unquoted shell control
operator or redirection and insert the binding there. Operators inside
quotes and command substitutions are ignored, and explicit Spotlight
bindings inside shell scripts remain untouched.

Addresses the Sentry bot review on #1351.

Co-authored-by: Aditya Mathur <MathurAditya724@users.noreply.github.com>
Comment thread packages/cli/src/lib/wrangler.ts Resolved
cursoragent and others added 2 commits August 3, 2026 18:53
The skill generator collects every bash block from command docs as a
runnable CLI example. The explanatory block containing only '--var
SENTRY_SPOTLIGHT:...' therefore appeared as a bare command under sentry
local, detached from its Cloudflare context.

Render the flag inline in the source fragment and regenerate the skill
reference, preserving the explanation in docs while keeping the agent
skill's examples executable.

Co-authored-by: Aditya Mathur <MathurAditya724@users.noreply.github.com>
Inspect selected package.json script content before injecting so an
explicit SENTRY_SPOTLIGHT binding is never duplicated or overridden.

The wider review also tightens command detection and argument forwarding:
only supported Wrangler executable positions match, quoted shell text is
ignored, shell values are escaped, pnpm/yarn/bun avoid npm's separator,
shorthand scripts and Windows paths work, custom configs inside scripts
are detected, and compound package scripts warn instead of claiming a
binding was injected into the wrong command.

Addresses the second Sentry bot review on #1351.

Co-authored-by: Aditya Mathur <MathurAditya724@users.noreply.github.com>
@MathurAditya724
MathurAditya724 merged commit 94a4ca5 into main Aug 3, 2026
31 checks passed
@MathurAditya724
MathurAditya724 deleted the cursor/inject-wrangler-spotlight-binding-27d6 branch August 3, 2026 19:27
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants