Skip to content

Conversation

@icecrasher321
Copy link
Collaborator

Summary

Standard system in block resolver class extracted and reused.

Function / Code resolution bugs fixed.

Other edge cases like single letter block names, and _ collisions handled.

Type of Change

  • Bug fix

Testing

Added tests + 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 Jan 22, 2026

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

1 Skipped Deployment
Project Deployment Review Updated (UTC)
docs Skipped Skipped Jan 22, 2026 8:26pm

Request Review

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 22, 2026

Greptile Summary

Extracted duplicate block reference resolution logic into a new resolveBlockReference utility function that consolidates schema validation across the codebase. The PR also fixes several edge cases including single-letter block names (regex now uses ? quantifier), underscore collision handling (using _1 for _ and _0 for .), and proper undefined handling in JavaScript/Python contexts.

Key improvements:

  • Created block-reference.ts utility with centralized resolution logic and schema validation
  • Removed 120+ lines of duplicated code from block.ts resolver
  • Added comprehensive test suite with 255 lines covering edge cases
  • Fixed regex pattern to support single-letter block names: [a-zA-Z_](?:[a-zA-Z0-9_${REFERENCE.PATH_DELIMITER}]*[a-zA-Z0-9_])?
  • Improved variable name escaping to handle underscore collisions
  • Added blockOutputSchemas parameter throughout execution pipeline
  • Fixed undefined value handling in isolated-vm worker and code generation

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • Score reflects excellent code consolidation with comprehensive test coverage (255 test lines), proper handling of edge cases (single-letter names, underscore collisions, undefined values), and consistent threading of blockOutputSchemas throughout the execution pipeline
  • No files require special attention

Important Files Changed

Filename Overview
apps/sim/executor/utils/block-reference.ts New utility file that extracts and consolidates block reference resolution logic with schema validation
apps/sim/executor/variables/resolvers/block.ts Refactored to use new resolveBlockReference utility, removing 120+ lines of duplicated schema validation logic
apps/sim/app/api/function/execute/route.ts Updated regex to support single-letter block names, improved underscore collision handling, added undefined handling
apps/sim/executor/utils/block-data.ts Enhanced to collect and return blockOutputSchemas alongside block data for validation

Sequence Diagram

sequenceDiagram
    participant Handler as Block Handler
    participant Collector as collectBlockData
    participant Executor as Function Execute API
    participant Resolver as resolveBlockReference
    participant Schema as Output Schema

    Handler->>Collector: collectBlockData(ctx)
    Collector->>Schema: getBlockOutputs(blockType)
    Schema-->>Collector: outputSchema
    Collector-->>Handler: {blockData, blockNameMapping, blockOutputSchemas}
    
    Handler->>Executor: executeTool with schemas
    Executor->>Executor: resolveTagVariables()
    Executor->>Resolver: resolveBlockReference(blockName, fieldPath, context)
    
    Resolver->>Resolver: normalize blockName
    Resolver->>Resolver: lookup blockId from mapping
    
    alt Schema exists
        Resolver->>Resolver: isPathInSchema(schema, pathParts)
        alt Path invalid
            Resolver-->>Executor: throw InvalidFieldError
        else Path valid
            Resolver->>Resolver: navigatePath(blockOutput, pathParts)
            Resolver-->>Executor: {value, blockId}
        end
    else No schema
        Resolver->>Resolver: navigatePath(blockOutput, pathParts)
        Resolver-->>Executor: {value, blockId}
    end
    
    Executor->>Executor: Replace tag with safe variable
    Executor-->>Handler: Execution result
Loading

cursor[bot]

This comment was marked as outdated.

@icecrasher321
Copy link
Collaborator Author

@cursor review

cursor[bot]

This comment was marked as outdated.

@icecrasher321
Copy link
Collaborator Author

@cursor review

cursor[bot]

This comment was marked as outdated.

@icecrasher321
Copy link
Collaborator Author

@cursor review

Copy link

@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.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

@icecrasher321 icecrasher321 merged commit fcd0240 into staging Jan 22, 2026
11 checks passed
@icecrasher321 icecrasher321 deleted the fix/resolver-bugs-2 branch January 22, 2026 20:38
waleedlatif1 added a commit that referenced this pull request Jan 22, 2026
…lution consolidation, helm updates (#2946)

* improvement(workflow-item): stabilize avatar layout and fix name truncation (#2939)

* improvement(workflow-item): stabilize avatar layout and fix name truncation

* fix(avatars): revert overflow bg to hardcoded color for contrast

* fix(executor): stop parallel execution when block errors (#2940)

* improvement(helm): add per-deployment extraVolumes support (#2942)

* fix(gmail): expose messageId field in read email block (#2943)

* fix(resolver): consolidate reference resolution  (#2941)

* fix(resolver): consolidate code to resolve references

* fix edge cases

* use already formatted error

* fix multi index

* fix backwards compat reachability

* handle backwards compatibility accurately

* use shared constant correctly

* feat(router): expose reasoning output in router v2 block (#2945)

* fix(copilot): always allow, credential masking (#2947)

* Fix always allow, credential validation

* Credential masking

* Autoload

* fix(executor): handle condition dead-end branches in loops (#2944)

---------

Co-authored-by: Vikhyath Mondreti <vikhyathvikku@gmail.com>
Co-authored-by: Siddharth Ganesan <33737564+Sg312@users.noreply.github.com>
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