Skip to content

Conversation

@icecrasher321
Copy link
Collaborator

Summary

Integer overflow leading to status update failure for stale executions that failed with network error from model providers, etc

Type of Change

  • Bug fix

Testing

Tested manually

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel
Copy link

vercel bot commented Feb 2, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Feb 2, 2026 9:20am

Request Review

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 2, 2026

Greptile Overview

Greptile Summary

What changed

This PR adjusts the cleanup-stale-executions cron route to avoid an integer overflow that prevented stale execution status updates (notably for executions that failed due to network/provider errors).

How it fits in

apps/sim/app/api/cron/cleanup-stale-executions/route.ts is part of the Sim app’s scheduled maintenance endpoints. It identifies executions that have become stale and updates their status accordingly; this change makes those updates reliable even for very large age/duration values that previously overflowed numeric bounds.

Confidence Score: 3/5

  • This PR is likely safe to merge, but should be double-checked around date arithmetic and DB query semantics for edge cases.
  • Only one file is changed and the intent (avoiding overflow) is clear, but I could not fully validate the runtime behavior for all providers/status transitions without seeing comprehensive tests or broader call sites; cron routes are also easy to subtly mis-handle time units.
  • apps/sim/app/api/cron/cleanup-stale-executions/route.ts

Important Files Changed

Filename Overview
apps/sim/app/api/cron/cleanup-stale-executions/route.ts Adjusts stale execution cleanup logic to avoid integer overflow during age/timeout calculations; verify time unit conversions and DB update conditions for edge cases.

Sequence Diagram

sequenceDiagram
  autonumber
  participant Scheduler as Cron/Scheduler
  participant Route as cleanup-stale-executions route
  participant DB as Database

  Scheduler->>Route: HTTP request (cron invocation)
  Route->>DB: Query stale executions
  DB-->>Route: Stale execution rows
  loop each stale execution
    Route->>Route: Compute age/timeout threshold (overflow-safe)
    Route->>DB: Update execution status (failed/timeout)
    DB-->>Route: Update result
  end
  Route-->>Scheduler: 200 OK + summary
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

1 file reviewed, no comments

Edit Code Review Agent Settings | Greptile

@icecrasher321 icecrasher321 merged commit b738550 into staging Feb 2, 2026
12 checks passed
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