Skip to content

Conversation

@icecrasher321
Copy link
Collaborator

Summary

Simplify null check for block metadata.

Type of Change

  • Bug fix

Testing

Locally against staging agent

@vercel
Copy link

vercel bot commented Sep 23, 2025

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

Project Deployment Preview Comments Updated (UTC)
sim Building Building Preview Comment Sep 23, 2025 11:03pm
1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
docs Skipped Skipped Sep 23, 2025 11:03pm

@icecrasher321 icecrasher321 merged commit 603b547 into staging Sep 23, 2025
4 of 5 checks passed
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Greptile Overview

Summary

This PR replaces the recursive pruneNullishDeep function with a simpler removeNullish function in the copilot blocks metadata tool. The change simplifies null checking by only removing null/undefined values at the top level of objects, rather than recursively cleaning nested structures.

Key Changes:

  • Removed complex recursive pruneNullishDeep function (23 lines)
  • Added simpler removeNullish function (12 lines) that only handles top-level filtering
  • Updated function call on line 233 to use the new function name

Concerns:

  • The new implementation may leave null/undefined values in nested objects and arrays
  • This could potentially cause issues downstream if consumer code expects fully cleaned metadata
  • The change reduces the thoroughness of null value filtering without clear justification

Confidence Score: 2/5

  • This PR introduces potential regressions by removing deep null cleaning functionality
  • Score reflects the significant change in behavior from recursive to shallow null removal, which could leave problematic null values in nested metadata structures and potentially break downstream consumers
  • The get-blocks-metadata-tool.ts file requires attention due to the behavioral change in null handling

Important Files Changed

File Analysis

Filename        Score        Overview
apps/sim/lib/copilot/tools/server/blocks/get-blocks-metadata-tool.ts 2/5 Replaced recursive pruneNullishDeep function with shallow removeNullish function, potentially leaving null values in nested objects

Sequence Diagram

sequenceDiagram
    participant Client as Client/Copilot
    participant Tool as getBlocksMetadataServerTool
    participant Registry as blockRegistry
    participant Processor as removeNullish
    
    Client->>Tool: execute({blockIds})
    loop for each blockId
        Tool->>Registry: blockRegistry[blockId]
        Registry-->>Tool: blockConfig
        Tool->>Tool: build metadata object
        Tool->>Processor: removeNullish(metadata)
        Note over Processor: OLD: pruneNullishDeep (recursive)<br/>NEW: removeNullish (shallow only)
        Processor-->>Tool: filtered metadata
        Tool->>Tool: result[blockId] = metadata
    end
    Tool-->>Client: {metadata: result}
Loading

1 file reviewed, 2 comments

Edit Code Review Bot Settings | Greptile

Comment on lines +373 to 385
function removeNullish(obj: any): any {
if (!obj || typeof obj !== 'object') return obj

const cleaned: any = Array.isArray(obj) ? [] : {}

for (const [key, value] of Object.entries(obj)) {
if (value !== null && value !== undefined) {
cleaned[key] = value
}
return output as unknown as T
}
return value

return cleaned
}
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: The simplified removeNullish function only removes null/undefined values at the top level, unlike the previous pruneNullishDeep which recursively cleaned nested objects and arrays. This may leave null/undefined values in nested structures that could cause issues downstream.

function removeNullish(obj: any): any {
if (!obj || typeof obj !== 'object') return obj

const cleaned: any = Array.isArray(obj) ? [] : {}
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: The function doesn't handle recursion anymore. If the metadata object contains nested arrays or objects with null/undefined values, they will remain unfiltered.

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