Skip to content

fix(function): report code-placeholder compiler invariants as server failures - #8402

Merged
waleedlatif1 merged 2 commits into
stagingfrom
fix/code-placeholder-invariant-errors
Sep 29, 2026
Merged

waleedlatif1 merged 2 commits into
stagingfrom
fix/code-placeholder-invariant-errors

Conversation

@waleedlatif1

@waleedlatif1 waleedlatif1 commented Sep 29, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Two code-placeholder compiler failures are broken invariants in Sim's own compiler, not problems in the user's code: overlapping source edits (applySourceEdits) and exhausting the Python marker attempts (each marker is a hash of the code itself, so user code cannot occupy them)
  • They threw CodePlaceholderCompileError, so the Function route answered them with 422 exactly like a user syntax error
  • They now throw a sibling CodePlaceholderInvariantError. It deliberately does not extend CodePlaceholderCompileError, so the route's only instanceof check doesn't match it and it falls through to the existing 500 path (the same path other unexpected compiler crashes already take). A subclass or a kind flag would have kept matching that check and stayed 422
  • Exhausting the JavaScript parser-sentinel space stays a user compile error: a sentinel is as long as its placeholder, so code under the length cap can contain every sentinel a short placeholder could take
  • User placeholder and syntax errors are unchanged (422). No other caller catches these errors by type

Type of Change

  • Bug fix

Testing

  • Overlapping edits throw CodePlaceholderInvariantError and not CodePlaceholderCompileError (fails on the previous code)
  • Code that packs every $xyz$ sentinel before return {{a}} still rejects with CodePlaceholderCompileError
  • Compiler and Function route suites, type-check, lint and all audits pass

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

vercel Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

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

1 Skipped Deployment
Project Deployment Actions Updated
docs Skipped Skipped Sep 29, 2026 4:46am UTC

Request Review

@cubic-dev-ai cubic-dev-ai 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.

No issues found across 4 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Re-trigger cubic

@greptile-apps

greptile-apps Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium risk] Changes error classification in code placeholder compilation.

The PR appears safe to merge; no outstanding finding or new actionable defect was identified in its current changeset.

Summary

The PR separates compiler-invariant failures from user compile errors so overlapping edits and Python marker exhaustion follow the Function route’s server-error path. It also tests that user-controlled JavaScript sentinel exhaustion remains a compile error.

Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart LR
  Compiler[Placeholder compiler] --> Error{Error type}
  Error -->|Compile error| Client[Function route: 422]
  Error -->|Invariant error| Server[Function route: 500]
Loading

Reviews (3) · Last reviewed commit: "fix(function): keep an exhausted JavaScr..."

Comment thread apps/sim/lib/execution/code-placeholders/compiler.test.ts Outdated
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Sep 29, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai 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.

No issues found across 4 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Re-trigger cubic

…failures

Overlapping source edits and exhausted parser-sentinel/Python-marker allocation are broken compiler invariants, not problems in the user's code, but they threw CodePlaceholderCompileError and the Function route answered them with 422 like a user syntax error. They now throw a sibling CodePlaceholderInvariantError, which the route's instanceof check does not match, so it falls through to the existing 500 path. User placeholder and syntax errors keep their 422.
…pile error

User code can occupy every sentinel a short placeholder could take, so running
out of them is the code's fault, not a compiler invariant.
@waleedlatif1
waleedlatif1 force-pushed the fix/code-placeholder-invariant-errors branch from 8405d02 to 6bbc799 Compare September 29, 2026 04:46
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Sep 29, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai 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.

No issues found across 3 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Re-trigger cubic

@waleedlatif1
waleedlatif1 merged commit b08cd5f into staging Sep 29, 2026
33 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/code-placeholder-invariant-errors branch September 29, 2026 05:15

This branch was previously deployed

1 inactive deployment
Preview — 6bbc799f Deployed Sep 29, 2026 by vercel[bot]
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.

1 participant