Skip to content

fix(cli): guard options before setting build in trigger-config-strip - #5181

Open
Sai-Likitha-Madisetty wants to merge 1 commit into
triggerdotdev:mainfrom
Sai-Likitha-Madisetty:fix/issue-5165-trigger-config-strip
Open

Sai-Likitha-Madisetty wants to merge 1 commit into
triggerdotdev:mainfrom
Sai-Likitha-Madisetty:fix/issue-5165-trigger-config-strip

Conversation

@Sai-Likitha-Madisetty

Copy link
Copy Markdown

Guards against options being undefined or a non-object before setting options.build = {} inside the trigger-config-strip esbuild plugin.

Closes #5165

Checklist

  • I have followed every step in the contributing guide
  • The PR title follows the convention.
  • I ran and tested the code works

Testing

Inspected configPlugin in packages/cli-v3/src/config.ts and verified the diff (+3 lines, -1 line) cleanly guards options.build = {}.

Changelog

Guarded options before assigning options.build = {} in trigger-config-strip.

@changeset-bot

changeset-bot Bot commented Dec 5, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 4a05d8b

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@coderabbitai

coderabbitai Bot commented Dec 5, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Walkthrough

configPlugin now checks that the extracted config options exist and are objects before assigning an empty object to the config’s build property. Previously, it assigned options.build without this check.

Severity of issue fixed: Medium

Merge Risk: Moderate · up to 4a05d

The guard stops the deploy crash when the extracted config options are missing. It also lets some unusual config shapes build without error while leaving build-time code in the bundle, or overwriting an unrelated export. The CLI behavior for those cases should be tightened before merge.

Pre-merge checks: Passed 3 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Description check Inconclusive The description states the guard purpose and links issue #5165, and it ticks the title-convention checkbox. It has no real Testing section. The author only inspected the diff and did not run or test t… Describe real test steps in the Testing section. State whether the deploy failure from issue #5165 was reproduced and whether the fix resolved it. Mark the 'I ran and tested the code works' checkbox only after running the code. Add a Screen…
Passed Passed checks: 3 passed

Check name Status Explanation
Title check Passed The title names the change: a guard on options before setting build in the trigger-config-strip plugin, in the cli package. It matches the raw summary, which says configPlugin now sets build only when…
Linked Issues check Passed Issue #5165 reports that trigger.dev deploy fails during "Building trigger code" with Cannot set properties of undefined (setting 'build') from the trigger-config-strip esbuild plugin. At the re…
Out of Scope Changes check Passed The whole-PR diff against the merge base changes one file, packages/cli-v3/src/config.ts. It wraps the existing options.build = {} assignment in an if (options && typeof options === "object") ch…
Full details: Title check

Explanation

The title names the change: a guard on options before setting build in the trigger-config-strip plugin, in the cli package. It matches the raw summary, which says configPlugin now sets build only when options exist and are objects. The title follows the conventional commit form and is specific.

Full details: Linked Issues check

Explanation

Issue #5165 reports that trigger.dev deploy fails during "Building trigger code" with Cannot set properties of undefined (setting 'build') from the trigger-config-strip esbuild plugin. At the reviewed head, configPlugin in packages/cli-v3/src/config.ts only assigns options.build = {} when options is truthy and typeof options === "object". This removes the exact throw site named in the issue. The guard does not change the normal path, where options is an object and build is still stripped. The issue does not specify a fix or required tests. The PR does not add a test, and the author states the code was not run. Whether the deploy succeeds for the reporter's project is not verified. The guard also means that, when options is not an object, the build key is not stripped. This is a silent behavior and was not addressed in the PR description.

Full details: Out of Scope Changes check

Explanation

The whole-PR diff against the merge base changes one file, packages/cli-v3/src/config.ts. It wraps the existing options.build = {} assignment in an if (options && typeof options === "object") check. This directly addresses issue #5165. No unrelated code, refactoring, or documentation changes are present. The raw summary's +3/-1 line count matches the diff.

Full details: Description check

Explanation

The description states the guard purpose and links issue #5165, and it ticks the title-convention checkbox. It has no real Testing section. The author only inspected the diff and did not run or test the code. The Changelog entry is present. The Screenshots section is absent, and the Testing section does not describe runnable steps.

Resolution

Describe real test steps in the Testing section. State whether the deploy failure from issue #5165 was reproduced and whether the fix resolved it. Mark the 'I ran and tested the code works' checkbox only after running the code. Add a Screenshots entry or remove the placeholder if none applies. The Closes line should use the issue reference from the template.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments

Major 1
  1. Specifier-exported configs keep build extensions after this change.
Minor 1
  1. Only rewrite the selected config file.
Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f61701dc-4b20-485d-80f0-35f1cd64fe0c
Commits

Reviewing files that changed from the base of the PR and between 7e40289 and 4a05d8b.

Files selected for processing: 1

  • packages/cli-v3/src/config.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Review details

Additional context used

Code guidelines: 5

.claude/rules/sdk-packages.md — auto-discovered
.cursor/rules/writing-tasks.mdc — auto-discovered
packages/cli-v3/AGENTS.md — auto-discovered
AGENTS.md — auto-discovered
.github/copilot-instructions.md — auto-discovered
Path-based instructions: 5

Source excerpt: Changes to `packages/` are **customer-facing**.

CodeRabbit inference engine (.claude/rules/sdk-packages.md)

Files:

  • packages/cli-v3/src/config.ts
Source excerpt: You MUST import from `@trigger.dev/sdk` (NEVER `@trigger.dev/sdk/v3`) Source excerpt: You MUST NEVER use `client.defineJob` Source excerpt: YOU MUST `export` every task, including subtasks Source excerpt: Key points: Each ta...

CodeRabbit inference engine (.cursor/rules/writing-tasks.mdc)

Files:

  • packages/cli-v3/src/config.ts
Source excerpt: The `rules/` directory at the repo root contains versioned SDK documentation that gets installed alongside customer projects.

CodeRabbit inference engine (packages/cli-v3/AGENTS.md)

Files:

  • packages/cli-v3/src/config.ts
Source excerpt: Where test files go: **Packages:** follow the package's existing layout.

CodeRabbit inference engine (AGENTS.md)

Files:

  • packages/cli-v3/src/config.ts
Source excerpt: This is the repo for Trigger.dev, a background jobs platform written in TypeScript.

CodeRabbit inference engine (.github/copilot-instructions.md)

Files:

  • packages/cli-v3/src/config.ts
Learnings: 1

Learning: 2026-08-20T20:04:24.997Z

Learnt from: D-K-P
Repo: triggerdotdev/trigger.dev PR: 4743
File: apps/webapp/app/services/platformNotifications.server.ts:650-773
Timestamp: 2026-08-20T20:04:24.997Z
Learning: In this repository, `crumbs` markers and `#region crumbs` blocks are temporary development instrumentation that is removed before merge. Do not flag their presence or absence during code review in TypeScript files.

Applied to files:

  • packages/cli-v3/src/config.ts
Additional comments: 1

packages/cli-v3/src/config.ts: 1

135-135: Data Integrity & Integration

The re-export concern does not hold for this guard. The plugin's filter only matches the config file itself. The shared module named in the re-export is loaded by esbuild's normal resolution and does not pass through this onLoad. The guard only skips the build assignment when options is not an object, and the same input would previously have failed on that assignment. The guard therefore does not cause build dependencies from a shared module to enter the bundle.

: $mod.exports.config;

options.build = {};
if (options && typeof options === "object") {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Major · Data Integrity & Integration · Quick win

Supported by static analysis

Script executed:

# 1. Plugin source around the changed guard, with original line numbers.
cat -n packages/cli-v3/src/config.ts | sed -n '100,160p'

# 2. Declared and locked versions of the libraries behind the claim.
rg -n '"(c12|magicast|jiti)"' packages/cli-v3/package.json || test "$?" -eq 1
rg -n -A2 '^  (magicast|c12|jiti)@' pnpm-lock.yaml || test "$?" -eq 1

# 3. Installed sources, if the sandbox has them (node_modules is often absent).
for d in node_modules/magicast node_modules/.pnpm/magicast@0.3.4*/node_modules/magicast node_modules/.pnpm/c12@*/node_modules/c12; do
  test -d "$d" && echo "FOUND $d" && ls "$d"
done
test -d node_modules/.pnpm && rg -l -F 'defaultExport' node_modules/.pnpm/magicast@* 2>/dev/null | head -n 20 || true

Repository: triggerdotdev/trigger.dev

Length of output: 4778


Script executed:

# Locate export handling in the installed magicast 0.3.4 dist.
rg -n -e 'ExportSpecifier' -e 'ExportDefaultDeclaration' -e 'ExportNamedDeclaration' node_modules/.pnpm/magicast@0.3.4/node_modules/magicast/dist || test "$?" -eq 1

# Show the surrounding exports-proxy construction for any hit.
for f in $(rg -l -e 'ExportSpecifier' -e 'ExportDefaultDeclaration' node_modules/.pnpm/magicast@0.3.4/node_modules/magicast/dist || true); do
  echo "== $f"
  rg -n -C6 -e 'ExportSpecifier' -e 'ExportDefaultDeclaration' "$f" | head -n 120
done

Repository: triggerdotdev/trigger.dev

Length of output: 16701


Script executed:

# Read the exports-proxy lookup in the installed magicast 0.3.4 ESM dist, with original line numbers.
cat -n node_modules/.pnpm/magicast@0.3.4/node_modules/magicast/dist/index.mjs | sed -n '8595,8685p'

Repository: triggerdotdev/trigger.dev

Length of output: 3623


Specifier-exported configs keep build extensions after this change.

Before this change, a config exported as export { cfg as default } made the trigger-config-strip plugin throw at options.build = {}. The deploy failed. With the new guard at packages/cli-v3/src/config.ts:135, that case no longer fails. Magicast 0.3.4 does not resolve specifier exports for default, so options is undefined and the guard skips stripping. The build section and its extension imports stay in the bundle.

The guard turns a visible failure into a silent one. The worker then loads the build-only extension code that the strip step was meant to remove. Resolve the default export through its specifier, or fail the build when no default export object is found.


Minor · Functional Correctness · Quick win

Supported by static analysis

Script executed:

sed -n '95,170p' packages/cli-v3/src/config.ts
git diff 7e40289a7cfde2a391b487c0b22fedb3e5e46197 HEAD -- packages/cli-v3/src/config.ts

Repository: triggerdotdev/trigger.dev

Length of output: 3140


Script executed:

rg -n -F -e 'configFile' -- packages/cli-v3/src/config.ts || test "$?" -eq 1
rg -n -F -e 'configPlugin(' -- packages/cli-v3/src || test "$?" -eq 1
sed -n '40,75p' packages/cli-v3/src/config.ts | cat -n

Repository: triggerdotdev/trigger.dev

Length of output: 1860


Only rewrite the selected config file.

The filter matches any bundled file whose path ends in trigger.config.ts. A non-config file with that name and a resolveEnvVars export now builds without error. Its resolveEnvVars export is then set to undefined. Before this change, the same file failed the build. A task that imports that file and calls resolveEnvVars can now fail at runtime.

Limit the rewrite to the file at configFile. Other files that match the filter must load unchanged. Compare the loaded path with the resolved configFile path, not its basename.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: deploy fails with [plugin: trigger-config-strip] Cannot set properties of undefined (setting 'build')

1 participant