Skip to content

Conversation

@Sg312
Copy link
Contributor

@Sg312 Sg312 commented Dec 13, 2025

Summary

Fix copilot json state sanitization

Type of Change

  • Bug fix

Testing

Manual

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 Dec 13, 2025

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

1 Skipped Deployment
Project Deployment Review Updated (UTC)
docs Skipped Skipped Dec 13, 2025 1:52am

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Dec 13, 2025

Greptile Overview

Greptile Summary

This PR simplifies the JSON sanitization logic for the copilot feature by:

  • Extracting the sortKeysRecursively helper function for reuse
  • Simplifying responseFormat handling by moving the null/undefined check before the special case logic
  • Changing JSON parse error behavior from "skip field" to "pass through as-is"

Note: The isSensitiveSubBlock function and TRIGGER_PERSISTED_SUBBLOCK_IDS import are now dead code and could be cleaned up.

Confidence Score: 4/5

  • Safe to merge with minor cleanup opportunity for dead code
  • The changes are localized to sanitization logic, with clear intent to fix JSON state handling. The refactoring is straightforward. Minor dead code remains but doesn't affect functionality.
  • No files require special attention

Important Files Changed

File Analysis

Filename Score Overview
apps/sim/lib/workflows/sanitization/json-sanitizer.ts 4/5 Simplified responseFormat handling and extracted sortKeysRecursively helper. Left isSensitiveSubBlock function and TRIGGER_PERSISTED_SUBBLOCK_IDS import as dead code.

Sequence Diagram

sequenceDiagram
    participant Caller
    participant sanitizeSubBlocks
    participant sortKeysRecursively
    
    Caller->>sanitizeSubBlocks: subBlocks
    
    loop Each subBlock entry
        alt null/undefined value
            sanitizeSubBlocks-->>sanitizeSubBlocks: skip
        else key === 'responseFormat'
            alt string value
                sanitizeSubBlocks->>sanitizeSubBlocks: JSON.parse()
            end
            alt parsed is object
                sanitizeSubBlocks->>sortKeysRecursively: obj
                sortKeysRecursively-->>sanitizeSubBlocks: sorted obj
                sanitizeSubBlocks->>sanitizeSubBlocks: sanitized[key] = sorted
            else invalid JSON
                sanitizeSubBlocks->>sanitizeSubBlocks: sanitized[key] = original value
            end
        else condition-input type
            sanitizeSubBlocks->>sanitizeSubBlocks: sanitizeConditions()
        else tools array
            sanitizeSubBlocks->>sanitizeSubBlocks: sanitizeTools()
        else default
            sanitizeSubBlocks->>sanitizeSubBlocks: sanitized[key] = value
        end
    end
    
    sanitizeSubBlocks-->>Caller: sanitized record
Loading

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.

Additional Comments (1)

  1. apps/sim/lib/workflows/sanitization/json-sanitizer.ts, line 71-101 (link)

    style: isSensitiveSubBlock function is no longer called anywhere after removing sensitive field filtering. Can be removed along with the TRIGGER_PERSISTED_SUBBLOCK_IDS import on line 5.

1 file reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@Sg312 Sg312 merged commit d06d2b0 into staging Dec 13, 2025
10 checks passed
@waleedlatif1 waleedlatif1 deleted the fix/copilot-oversanitization branch December 13, 2025 04:18
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