Skip to content

Conversation

@workers-devprod
Copy link
Contributor

Fixes #2634.

🤖✨ Beep boop! I think I've squashed this bug! All automated tests are passing, but my silicon brain might have missed something—would love a human review before this gets merged.


  • Tests
    • Tests included/updated
    • Automated tests not possible - manual testing has been completed as follows:
    • Additional testing not necessary because:
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: This is an automated bug fix

penalosa and others added 11 commits January 28, 2026 16:10
Automated issue triage and fixing powered by OpenCode.
- Use string comparison for isTeamMember check (was comparing string to boolean)
- Add git user config for workers-devprod bot before commit
- Use env vars instead of template literals to prevent JS injection in parse step
- Use env vars instead of shell interpolation to prevent shell injection in test step
- Use randomized heredoc delimiter to prevent delimiter collision in patch capture
- Switch to anthropics/claude-code-action@v1
- Use 'prompt' and 'claude_args' instead of deprecated inputs
- Use structured_output with --json-schema for assessment parsing
- Rename workflow to 'Autofix' and branch prefix to 'autofix/'
- Reference AGENTS.md for guidelines
Claude Code action doesn't automatically fetch issue context in automation
mode, so we explicitly fetch issue title/body/labels and include them in
the prompts for both assessment and fix steps.
Automated fix generated by Autofix.

Closes #2634
@changeset-bot
Copy link

changeset-bot bot commented Jan 28, 2026

🦋 Changeset detected

Latest commit: 74fc73c

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@penalosa penalosa changed the base branch from main to opencode-issue-solver January 28, 2026 19:56
@penalosa penalosa changed the base branch from opencode-issue-solver to main January 28, 2026 19:56
@claude
Copy link
Contributor

claude bot commented Jan 28, 2026

Claude finished @workers-devprod's task —— View job


Changeset Review

All changesets look good

The changeset .changeset/wrangler-command-env-var.md passes validation:

  1. Version Type: Correctly marked as minor - this adds a new feature (environment variable)
  2. Changelog Quality: Clear description with a helpful usage example
  3. Markdown Headers: No problematic h1/h2/h3 headers used
  4. Analytics: Not applicable (no analytics collection)
  5. Dependabot: Not applicable (not a dependency update)
  6. Experimental Features: Not applicable (this is a stable feature addition)

The changeset follows all guidelines from .changeset/README.md:

  • Clear imperative title: "Add WRANGLER_COMMAND environment variable to custom build commands"
  • Informative body explaining the feature and its use cases
  • Includes a practical code example showing how to use the new variable
  • Appropriate version bump (minor for new feature)

@penalosa
Copy link
Contributor

@claude this PR doesn't have tests. Can you add some?

@claude
Copy link
Contributor

claude bot commented Jan 28, 2026

Claude finished @penalosa's task —— View job


✅ Tests Added Successfully

I've added comprehensive tests for the WRANGLER_COMMAND environment variable functionality.

Todo List

  • Analyze the changed files to understand the new functionality
  • Find existing test patterns in the wrangler package
  • Locate appropriate test files for the modified modules
  • Write tests for the WRANGLER_COMMAND functionality
  • Run tests to ensure they pass (pending CI)
  • Commit and push the changes

Analysis

The changes add a WRANGLER_COMMAND environment variable that gets passed to custom build commands. The variable contains the current Wrangler command being executed ("dev", "deploy", "versions upload", or "types"). This is implemented in:

  1. run-custom-build.ts:23 - Sets the environment variable when executing custom build commands
  2. BundlerController.ts:57 - Passes "dev" command to runCustomBuild
  3. entry.ts:129 - Passes the command parameter to runCustomBuild

Tests Added

I've added comprehensive tests to /packages/wrangler/src/__tests__/custom-build.test.ts that verify:

  • runCommand sets WRANGLER_COMMAND correctly for each command type ("dev", "deploy", "versions upload", "types")
  • runCommand doesn't set WRANGLER_COMMAND when wranglerCommand is undefined
  • runCustomBuild passes through WRANGLER_COMMAND for all command types
  • runCustomBuild doesn't set WRANGLER_COMMAND when no command is provided

The tests use the existing test infrastructure including mockConsoleMethods(), runInTempDir(), and proper console output verification patterns used throughout the codebase.

Changes Committed

  • Added 10 new test cases covering all scenarios for the WRANGLER_COMMAND environment variable
  • Committed and pushed to the autofix/issue-2634 branch
  • Tests will run in CI to verify they pass

The PR now has comprehensive test coverage for the new WRANGLER_COMMAND functionality as requested.


@pkg-pr-new
Copy link

pkg-pr-new bot commented Jan 28, 2026

create-cloudflare

npm i https://pkg.pr.new/create-cloudflare@12215

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/@cloudflare/kv-asset-handler@12215

miniflare

npm i https://pkg.pr.new/miniflare@12215

@cloudflare/pages-shared

npm i https://pkg.pr.new/@cloudflare/pages-shared@12215

@cloudflare/unenv-preset

npm i https://pkg.pr.new/@cloudflare/unenv-preset@12215

@cloudflare/vite-plugin

npm i https://pkg.pr.new/@cloudflare/vite-plugin@12215

@cloudflare/vitest-pool-workers

npm i https://pkg.pr.new/@cloudflare/vitest-pool-workers@12215

@cloudflare/workers-editor-shared

npm i https://pkg.pr.new/@cloudflare/workers-editor-shared@12215

@cloudflare/workers-utils

npm i https://pkg.pr.new/@cloudflare/workers-utils@12215

wrangler

npm i https://pkg.pr.new/wrangler@12215

commit: 74fc73c

Tests verify that:
- runCommand sets WRANGLER_COMMAND for dev, deploy, versions upload, and types commands
- runCommand doesn't set WRANGLER_COMMAND when wranglerCommand is undefined
- runCustomBuild properly passes through WRANGLER_COMMAND for all command types

Co-authored-by: Somhairle MacLeòid <penalosa@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Untriaged

Development

Successfully merging this pull request may close these issues.

🚀 Feature Request: Detect dev/publish during custom build command

2 participants