Skip to content

fix(trigger): skip canonical-paired members when validating required fields on deploy#4100

Closed
waleedlatif1 wants to merge 2 commits intostagingfrom
waleedlatif1/fix-trigger-canonical-validation
Closed

fix(trigger): skip canonical-paired members when validating required fields on deploy#4100
waleedlatif1 wants to merge 2 commits intostagingfrom
waleedlatif1/fix-trigger-canonical-validation

Conversation

@waleedlatif1
Copy link
Copy Markdown
Collaborator

Summary

  • buildProviderConfig now uses buildCanonicalIndex to group canonical pairs before validating required fields
  • Previously, both the basic (spreadsheetId) and advanced (manualSpreadsheetId) members of a canonical pair were validated independently — so selecting a spreadsheet via the file-selector still triggered a "Missing required fields" error because the advanced twin was empty
  • Two-pass fix: first collect all values and track which canonical groups are satisfied, then only flag missing required fields for groups with no value from any member

Type of Change

  • Bug fix

Testing

Tested manually — Google Sheets trigger with Spreadsheet and Sheet Tab selected via file/sheet selectors now deploys without "Missing required fields" error

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)

@cursor
Copy link
Copy Markdown

cursor bot commented Apr 10, 2026

PR Summary

Medium Risk
Touches deploy-time trigger validation for webhook configuration; mistakes could allow missing config through or block valid deployments, but the change is localized and uses existing canonical grouping logic.

Overview
Fixes a deploy-time validation bug where triggers with canonical basic/advanced paired fields could fail with “Missing required fields” even when one side of the pair was set.

buildProviderConfig now builds a canonical index and performs a two-pass scan: first collecting provided values and marking satisfied canonical groups, then only flagging required fields as missing when no member of a canonical group has a value.

Reviewed by Cursor Bugbot for commit c7ae3ef. Configure here.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Apr 10, 2026

Greptile Summary

This PR fixes a bug in buildProviderConfig where canonical-paired subblock twins (e.g., a file-selector spreadsheetId and its manual-input manualSpreadsheetId) were both validated independently for required fields. The fix introduces a two-pass approach: the first pass collects all non-empty values and marks canonical groups as satisfied, and the second pass skips the required-field check for any subblock whose canonical group was already satisfied by another member.

Confidence Score: 5/5

Safe to merge — targeted bug fix with correct two-pass canonical validation logic and no regressions introduced.

The change is minimal and well-scoped: it adds buildCanonicalIndex (an already-tested utility) and rewrites only the required-field validation logic in buildProviderConfig. The two-pass approach correctly handles both the satisfied-group skip and the pre-existing value-collection behavior. No P0 or P1 issues were found.

No files require special attention.

Important Files Changed

Filename Overview
apps/sim/lib/webhooks/deploy.ts Adds buildCanonicalIndex import and rewrites the required-field validation in buildProviderConfig to a two-pass approach that correctly skips canonical-paired twins when the group is already satisfied.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[buildProviderConfig called] --> B[buildCanonicalIndex from triggerDef.subBlocks]
    B --> C[Filter relevantSubBlocks\nmode: trigger or trigger-advanced]
    C --> D["Pass 1: Collect values\n(iterate relevantSubBlocks)"]
    D --> E{subBlock has\nnon-empty value?}
    E -- Yes --> F[Add to providerConfig]
    F --> G{Has canonicalParamId?}
    G -- Yes --> H[Mark canonicalId\nas satisfied]
    G -- No --> I[Continue]
    H --> I
    E -- No --> I
    I --> J{More subBlocks?}
    J -- Yes --> D
    J -- No --> K["Pass 2: Validate required fields\n(iterate relevantSubBlocks)"]
    K --> L{Value already\nin providerConfig?}
    L -- Yes --> M[Skip - continue]
    L -- No --> N{In a satisfied\ncanonical group?}
    N -- Yes --> M
    N -- No --> O{isFieldRequired?}
    O -- Yes --> P[Add to missingFields]
    O -- No --> Q[Continue]
    P --> Q
    Q --> R{More subBlocks?}
    R -- Yes --> K
    R -- No --> S[Return providerConfig\n+ missingFields]
Loading

Reviews (1): Last reviewed commit: "fix(trigger): skip canonical-paired memb..." | Re-trigger Greptile

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit c7ae3ef. Configure here.

if (isFieldRequired(subBlock, subBlockValues)) {
missingFields.push(subBlock.title || subBlock.id)
}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale baseConfig values bypass required field validation

Medium Severity

The second-pass guard providerConfig[subBlock.id] !== undefined can be satisfied by stale values inherited from baseConfig (spread into providerConfig at initialization), not just values set during the first pass. If triggerConfig contains a leftover entry for a field the user has since cleared, the required-field check is silently skipped, allowing deployment with missing required fields. The old code always validated against getConfigValue results regardless of providerConfig contents. A separate Set tracking first-pass fills would be more reliable than checking providerConfig.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit c7ae3ef. Configure here.

…sing required-field validation

Use a dedicated `filledSubBlockIds` Set populated during the first pass so the second-pass skip guard is based solely on live `getConfigValue` results, not on stale entries spread from `baseConfig` (`triggerConfig`).
@vercel
Copy link
Copy Markdown

vercel bot commented Apr 10, 2026

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Apr 10, 2026 9:49pm

Request Review

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

Addressed the Cursor Bugbot comment (discussion_r3066873288):

Bug confirmed. The second-pass guard providerConfig[subBlock.id] !== undefined was falsely satisfied by stale entries inherited from baseConfig (spread from triggerConfig at line 180). If a user had previously set a value for a required field and then cleared it, the leftover entry in triggerConfig would cause required-field validation to be silently skipped — allowing deployment with missing required fields.

Fix: Introduced a dedicated filledSubBlockIds: Set<string> that is populated only during the first pass from live getConfigValue results. The second-pass skip guard now checks filledSubBlockIds.has(subBlock.id) instead of providerConfig[subBlock.id] !== undefined, so stale baseConfig values can never mask a missing required field.

Pushed in commit 402462a.

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

Closing in favour of #4101 which includes all of these changes plus the broader polling trigger fixes — combined into a single PR since they're tightly coupled.

@waleedlatif1 waleedlatif1 deleted the waleedlatif1/fix-trigger-canonical-validation branch April 11, 2026 00:51
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