-
Notifications
You must be signed in to change notification settings - Fork 498
capture freestyle error #969
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
WalkthroughAdded defensive guards in two email-rendering functions to detect a missing execution result. When executeResult.data.result is absent, the code constructs a StackAssertionError with full context, calls captureError with a specific tag, and throws the error; successful paths now read from executeResult.data.result. Changes
Sequence Diagram(s)sequenceDiagram
participant Caller
participant Renderer as EmailRenderer
participant Executor as FreestyleExecutor
Caller->>Renderer: renderEmailWithTemplate(...)
Renderer->>Executor: execute(freestyle, inputs)
Executor-->>Renderer: executeResult (status / data)
alt executeResult has data.result
Renderer-->>Caller: return executeResult.data.result
else missing data.result
Renderer->>Renderer: build StackAssertionError(context)
Renderer->>Renderer: captureError(error, "freestyle-no-result")
Renderer--xCaller: throw StackAssertionError
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Points to review:
Poem
Pre-merge checks and finishing touches❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
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. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Greptile Overview
Summary
Added defensive error handling in email rendering functions to detect and capture cases where Freestyle script execution succeeds but returns no result.
- Checks for missing
executeResult.data.resultafter successful Freestyle execution in bothrenderEmailWithTemplateandrenderEmailsWithTemplateBatched - Uses
captureErrorto log diagnostic information when this edge case occurs - Returns user-friendly error message instead of allowing undefined to propagate
Confidence Score: 5/5
- This PR is safe to merge with minimal risk
- The change adds defensive error handling for an edge case without modifying existing logic paths. The pattern is consistent across both functions and follows existing error handling conventions in the codebase.
- No files require special attention
Important Files Changed
File Analysis
| Filename | Score | Overview |
|---|---|---|
| apps/backend/src/lib/email-rendering.tsx | 5/5 | Added defensive error handling to capture and log cases where Freestyle execution succeeds but returns no result |
Sequence Diagram
sequenceDiagram
participant Caller
participant EmailRenderer
participant Freestyle
participant ErrorCapture
Caller->>EmailRenderer: renderEmailWithTemplate()
EmailRenderer->>EmailRenderer: bundleJavaScript()
EmailRenderer->>Freestyle: executeScript()
alt Execution Error
Freestyle-->>EmailRenderer: Result.error(error)
EmailRenderer-->>Caller: Return error
else Execution Success
Freestyle-->>EmailRenderer: Result.ok(data)
EmailRenderer->>EmailRenderer: Check if data.result exists
alt No Result (New Check)
EmailRenderer->>ErrorCapture: captureError("freestyle-no-result")
EmailRenderer-->>Caller: Return error message
else Result Exists
EmailRenderer-->>Caller: Return Result.ok(data.result)
end
end
1 file reviewed, no comments
Summary by CodeRabbit