Skip to content

fix: Scheduled task test page crashes on empty payloads#3411

Closed
avasis-ai wants to merge 1 commit intotriggerdotdev:mainfrom
avasis-ai:fix/scheduled-task-empty-payload-crash
Closed

fix: Scheduled task test page crashes on empty payloads#3411
avasis-ai wants to merge 1 commit intotriggerdotdev:mainfrom
avasis-ai:fix/scheduled-task-empty-payload-crash

Conversation

@avasis-ai
Copy link
Copy Markdown

Summary

Fixes #3316

The test page for a scheduled task throws an uncaught TypeError and fails to load when any run for that task has an empty payload ("").

Problem

In TestTaskPresenter.server.ts, getScheduleTaskRunPayload calls parsePacket which returns undefined when data is empty. The function then accesses packet.timezone on undefined, throwing a TypeError that crashes the presenter.

Fix

Added a null guard for packet in getScheduleTaskRunPayload. When parsePacket returns undefined (empty/malformed payload), the function now returns { success: false } instead of crashing. The existing .filter(Boolean) in the caller already handles this case by silently skipping invalid runs.

Reproduction

  1. Deploy a scheduled task to a staging/production environment
  2. Insert a TaskRun record with payload = "" and payloadType = "application/json"
  3. Navigate to the test page for that task
  4. Before fix: Page fails to load
  5. After fix: Page loads normally, empty-payload runs are skipped

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 18, 2026

⚠️ No Changeset found

Latest commit: 696ee34

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

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 18, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 171ef73f-30e3-43b7-9ce7-b1df4569a35c

📥 Commits

Reviewing files that changed from the base of the PR and between 7d7ebdd and 696ee34.

📒 Files selected for processing (1)
  • apps/webapp/app/presenters/v3/TestTaskPresenter.server.ts

Walkthrough

The getScheduleTaskRunPayload function in TestTaskPresenter.server.ts now includes an early return that explicitly handles falsy values from parsePacket. Previously, the function proceeded assuming packet was always defined, which could cause errors when accessing or modifying properties like timezone on a null or undefined value. The fix adds a guard clause that returns { success: false as const } immediately if parsePacket returns a falsy value.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown
Contributor

Hi @avasis-ai, thanks for your interest in contributing!

This project requires that pull request authors are vouched, and you are not in the list of vouched users.

This PR will be closed automatically. See https://github.com/triggerdotdev/trigger.dev/blob/main/CONTRIBUTING.md for more details.

@github-actions github-actions bot closed this Apr 18, 2026
Copy link
Copy Markdown
Contributor

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

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 potential bugs to report.

View in Devin Review to see 1 additional finding.

Open in Devin Review

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: Scheduled task test page crashes when previous runs have empty payloads

2 participants