Skip to content

fix(webapp): clamp run priority so a large value can't fail run creation - #4512

Merged
ericallam merged 1 commit into
mainfrom
feature/tri-12967-fix-unbounded-run-priority-overflows-the-priorityms-int4
Aug 5, 2026
Merged

fix(webapp): clamp run priority so a large value can't fail run creation#4512
ericallam merged 1 commit into
mainfrom
feature/tri-12967-fix-unbounded-run-priority-overflows-the-priorityms-int4

Conversation

@ericallam

Copy link
Copy Markdown
Member

Summary

Triggering a run with a very large priority could fail run creation outright with an opaque database error. priority is multiplied by 1000 and stored in a 32-bit integer column, with nothing bounding it, so a big enough value overflowed the column and the create failed. The trigger now caps the value to the highest supported priority instead of erroring, so the run is still created.

Fix

priorityMs (the stored priority * 1000) now goes through a clampPriorityMs helper before the write. It rounds to a whole number and clamps into the column range at both ends, so only a valid integer ever reaches the column and an out-of-range priority caps rather than failing. Single and batch triggers share the write path, so both are covered.

@changeset-bot

changeset-bot Bot commented Aug 5, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: cc032d7

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

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

The change adds clampPriorityMs, which converts priority values to rounded milliseconds and clamps them to the PostgreSQL int4 range. Run triggering now uses this helper instead of direct multiplication. Tests cover conversion, rounding, overflow, safe values, and integer-range invariants. A change note documents the new behavior.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the problem and fix, but it omits the required issue reference, checklist, testing, changelog, and screenshots sections. Add the required template sections, including the issue reference, checklist, testing steps, changelog entry, and screenshots or an explicit not-applicable note.
✅ Passed checks (4 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the main change: clamping large run priority values to prevent run creation failures.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/tri-12967-fix-unbounded-run-priority-overflows-the-priorityms-int4

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.

@ericallam
ericallam force-pushed the feature/tri-12967-fix-unbounded-run-priority-overflows-the-priorityms-int4 branch from 2711797 to cc032d7 Compare August 5, 2026 13:57
@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@ericallam
ericallam marked this pull request as ready for review August 5, 2026 15:00

@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 found 1 potential issue.

Open in Devin Review

Comment thread apps/webapp/app/v3/utils/priority.ts
@ericallam
ericallam merged commit 771937a into main Aug 5, 2026
43 checks passed
@ericallam
ericallam deleted the feature/tri-12967-fix-unbounded-run-priority-overflows-the-priorityms-int4 branch August 5, 2026 15:28
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.

2 participants