You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(cli): guard options before setting build in trigger-config-strip - #5181
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
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: 3 · 1
Failed checks: 1 inconclusive
Check name
Status
Explanation
Resolution
Description check
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 checks: 3 passed
Check name
Status
Explanation
Title check
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
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
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.
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.
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...
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.
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).fordin node_modules/magicast node_modules/.pnpm/magicast@0.3.4*/node_modules/magicast node_modules/.pnpm/c12@*/node_modules/c12;dotest -d "$d"&&echo"FOUND $d"&& ls "$d"donetest -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.forfin$(rg -l -e 'ExportSpecifier' -e 'ExportDefaultDeclaration' node_modules/.pnpm/magicast@0.3.4/node_modules/magicast/dist || true);doecho"== $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
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Guards against
optionsbeingundefinedor a non-object before settingoptions.build = {}inside thetrigger-config-stripesbuild plugin.Closes #5165
Checklist
Testing
Inspected
configPlugininpackages/cli-v3/src/config.tsand verified the diff (+3lines,-1line) cleanly guardsoptions.build = {}.Changelog
Guarded
optionsbefore assigningoptions.build = {}intrigger-config-strip.