sim icon indicating copy to clipboard operation
sim copied to clipboard

Bug: Incomplete fallback for corrupted [object Object] display values in getDisplayValue()

Open PlaneInABottle opened this issue 10 months ago • 1 comments

Description

The getDisplayValue() function in the workflow block component has an incomplete fallback handler for corrupted [object Object] string values. When a subblock value is corrupted upstream (converted to the literal string "[object Object]"), the fallback attempts to stringify it again, producing "\"[object Object]\"" instead of properly handling the error.

Location

  • File: /apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/workflow-block/workflow-block.tsx
  • Function: getDisplayValue()
  • Lines: 316-324

Root Cause

When a value is corrupted upstream (e.g., from calling String(object) which produces "[object Object]"), the fallback code at lines 316-324 attempts to handle it:

const stringValue = String(value)
if (stringValue === '[object Object]') {
  try {
    const json = JSON.stringify(parsedValue)  // ❌ If parsedValue is already the string "[object Object]", this produces "\\"[object Object]\\""`
    if (json.length <= 40) return json
    return `${json.slice(0, 37)}...`
  } catch {
    return '-'
  }
}

The issue: JSON.stringify("[object Object]") returns "\\"[object Object]\\"" which is not a helpful display value.

Related Bug

This is related to the critical data corruption bug in /apps/sim/tools/http/request.ts:130 where objects are converted to [object Object] strings during URL-encoded form serialization. When that upstream bug corrupts data, this frontend code doesn't handle the result gracefully.

Expected vs Actual

When parsedValue is:

  • An actual object: JSON.stringify() works correctly ✅
  • The corrupted string "[object Object]": JSON.stringify() produces "\\"[object Object]\\"" ❌

Suggested Fix

if (stringValue === '[object Object]') {
  // Only stringify if it's an actual object, not a corrupted string
  if (typeof parsedValue === 'object' && parsedValue !== null) {
    try {
      const json = JSON.stringify(parsedValue)
      if (json.length <= 40) return json
      return `${json.slice(0, 37)}...`
    } catch {
      return '-'
    }
  }
  // If it's already the corrupted string, just show placeholder
  return '-'
}

Impact

  • Severity: Medium (display/UI issue)
  • Scope: Affects subblock value display when upstream code corrupts objects
  • User Impact: Users see corrupted or malformed display values instead of clean error indicators

Code Context (lines 313-327)

// For non-array, non-object values, use original value for string conversion
const stringValue = String(value)
if (stringValue === '[object Object]') {
  try {
    const json = JSON.stringify(parsedValue)
    if (json.length <= 40) return json
    return `${json.slice(0, 37)}...`
  } catch {
    return '-'
  }
}

PlaneInABottle avatar Feb 01 '26 20:02 PlaneInABottle

I feel like this is redundant. Closing this one.

PlaneInABottle avatar Feb 01 '26 20:02 PlaneInABottle