-
Notifications
You must be signed in to change notification settings - Fork 3.3k
fix(variables, webhook): fix variable tag dropdown for escaped < and allow empty webhook payload #1851
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. |
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
Greptile Summary
This PR fixes two distinct bugs: variable tag dropdown incorrectly handling escaped < characters (like in comparisons < <block.output>), and webhook processor rejecting valid empty payloads.
Key Changes:
- Introduced
splitReferenceSegment()function to properly parse variable references when preceded by comparator operators (<,<=, etc.) - Updated
getTagSearchTerm()to uselastIndexOf()to find the most recent unclosed<bracket - Modified webhook processor to accept empty request bodies and empty JSON objects, returning
{body: {}, rawBody: ''}instead of 400 errors - Applied the new reference parsing logic consistently across tag dropdown, formatted text display, and code/condition input components
- Added comprehensive test coverage for the new parsing logic
- Removed unused
OAuthServiceimport
The changes are well-structured with proper separation of concerns. The new splitReferenceSegment utility is reusable and tested. The webhook change aligns with common webhook patterns where empty payloads are valid.
Confidence Score: 5/5
- This PR is safe to merge with minimal risk
- The changes are well-tested, focused, and address specific bugs without introducing complexity. The new
splitReferenceSegmentfunction has proper test coverage and is applied consistently. The webhook change is a simple, logical fix that improves compatibility. No breaking changes or security concerns identified. - No files require special attention
Important Files Changed
File Analysis
| Filename | Score | Overview |
|---|---|---|
| apps/sim/lib/workflows/references.ts | 5/5 | Added splitReferenceSegment function to properly handle escaped < characters in variable references and updated isLikelyReferenceSegment to use it |
| apps/sim/lib/webhooks/processor.ts | 5/5 | Changed to allow empty webhook payloads by returning empty objects instead of 400 errors |
| apps/sim/components/ui/tag-dropdown.tsx | 5/5 | Extracted getTagSearchTerm and updated search logic to use lastIndexOf for proper handling of escaped < characters |
| apps/sim/components/ui/formatted-text.tsx | 5/5 | Updated to use splitReferenceSegment for proper handling of escaped < in display text highlighting |
Sequence Diagram
sequenceDiagram
participant User
participant UI as Tag Dropdown/Input
participant Split as splitReferenceSegment
participant Filter as Tag Filter Logic
participant Display as Formatted Text
Note over User,Display: Scenario 1: Variable Tag Dropdown
User->>UI: Types "< <block.output>"
UI->>Split: getTagSearchTerm("< <block.output>", 18)
Split->>Split: lastIndexOf('<') finds last <
Split->>Split: Check if > after last <
Split-->>UI: Returns "" (empty search)
UI->>UI: Shows all tags
Note over User,Display: Scenario 2: Reference Highlighting
User->>Display: Displays text with "< <block.output>"
Display->>Split: splitReferenceSegment("< <block.output>")
Split->>Split: Finds last < at position 2
Split->>Split: Extracts leading="< ", reference="<block.output>"
Split-->>Display: {leading: "< ", reference: "<block.output>"}
Display->>Display: Render "< " as plain, "<block.output>" as blue
Note over User,Display: Scenario 3: Webhook Empty Payload
participant Webhook as Webhook Processor
participant Parser as parseWebhookBody
User->>Webhook: POST /webhook (empty body)
Webhook->>Parser: parseWebhookBody(request)
Parser->>Parser: Read body text
Parser->>Parser: Check if empty
Parser-->>Webhook: {body: {}, rawBody: ''}
Webhook->>Webhook: Continue processing with empty object
9 files reviewed, no comments
…allow empty webhook payload (#1851) * Fix << tags * Allow empty webhook body * Variable highlighting in loop conditions
…allow empty webhook payload (#1851) * Fix << tags * Allow empty webhook body * Variable highlighting in loop conditions
Summary
Fix variable tag dropdown for escaped < and allow empty webhook payload
Type of Change
Testing
Manual
Checklist