{"record":{"id":"6ac732dd8270a107","repo":"usebruno/bruno","slug":"error-message","errorCode":null,"errorMessage":"${error.message}","messagePattern":"\\$\\{error\\.message\\}","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/bruno-electron/src/ipc/collection.js","lineNumber":1937,"sourceCode":"      });\n    } catch (error) {\n      return Promise.reject(error);\n    }\n  });\n\n  ipcMain.handle('renderer:get-collection-security-config', async (event, collectionPath) => {\n    try {\n      return collectionSecurityStore.getSecurityConfigForCollection(collectionPath);\n    } catch (error) {\n      return Promise.reject(error);\n    }\n  });\n\n  ipcMain.handle('renderer:update-ui-state-snapshot', async (event, { type, data }) => {\n    try {\n      await snapshotManager.update({ type, data });\n    } catch (error) {\n      throw new Error(error.message);\n    }\n  });\n\n  ipcMain.handle('renderer:fetch-oauth2-credentials', async (event, { itemUid, request, collection }) => {\n    try {\n      if (request.oauth2) {\n        let requestCopy = _.cloneDeep(request);\n        const { uid: collectionUid, pathname: collectionPath, runtimeVariables, environments = [], activeEnvironmentUid } = collection;\n        const environment = _.find(environments, (e) => e.uid === activeEnvironmentUid);\n        const envVars = getEnvVars(environment);\n        const processEnvVars = getProcessEnvVars(collectionUid);\n        const partialItem = { uid: itemUid };\n        const requestTreePath = getTreePathFromCollectionToItem(collection, partialItem);\n        mergeVars(collection, requestCopy, requestTreePath);\n        const globalEnvironmentVariables = collection.globalEnvironmentVariables;\n        const promptVariables = collection.promptVariables;\n        interpolateVars(requestCopy, envVars, runtimeVariables, processEnvVars);\n        const { oauth2: { grantType, accessTokenUrl, refreshTokenUrl }, collectionVariables, folderVariables, requestVariables } = requestCopy || {};","sourceCodeStart":1919,"sourceCodeEnd":1955,"githubUrl":"https://github.com/usebruno/bruno/blob/9bdd81c7bdc57006e5f5ebffb79321a8d979f712/packages/bruno-electron/src/ipc/collection.js#L1919-L1955","documentation":"Re-thrown from the renderer:update-ui-state-snapshot handler when snapshotManager.update({type, data}) rejects. The handler wraps the original error in a fresh Error carrying only `.message`, discarding the stack/cause. The real failure lives inside snapshotManager (serialization, disk write, or schema validation).","triggerScenarios":"Calling renderer:update-ui-state-snapshot with a {type, data} payload whose data cannot be serialized/persisted by snapshotManager, or when the snapshot store is unwritable.","commonSituations":"Non-serializable data (functions, circular references, BigInt) in the snapshot payload; permission errors or disk-full on the snapshot file; concurrent snapshot writes corrupting state.","solutions":["Inspect the wrapped error.message — it carries snapshotManager's underlying reason.","Verify the snapshot directory is writable and has free disk space.","Ensure `data` is JSON-serializable (JSON.stringify it on the renderer side before sending).","Prefer `throw error` instead of `throw new Error(error.message)` in the handler so the stack is preserved."],"exampleFix":"// before\n  } catch (error) {\n    throw new Error(error.message);\n  }\n\n// after\n  } catch (error) {\n    throw error;\n  }","handlingStrategy":"try-catch","validationCode":"function isSerializable(value, seen = new WeakSet()) {\n  if (value === null || typeof value === 'undefined') return true;\n  const t = typeof value;\n  if (t === 'function' || t === 'symbol' || t === 'bigint') return false;\n  if (t !== 'object') return true;\n  if (seen.has(value)) return false;\n  seen.add(value);\n  return Object.values(value).every((v) => isSerializable(v, seen));\n}\nif (!isSerializable(data)) throw new Error('Snapshot data is not JSON-serializable');","typeGuard":null,"tryCatchPattern":"try {\n  await ipcRenderer.invoke('renderer:update-ui-state-snapshot', { type, data });\n} catch (err) {\n  // err.message is the wrapped snapshotManager message — log full context\n  console.error('snapshot update failed', err.message, { type });\n  // degrade gracefully: keep last-good snapshot, do not crash the UI\n}","preventionTips":["Send only JSON-serializable data over the IPC — strip functions/symbols/BigInt.","Keep the snapshot directory writable and monitor free disk space.","In the handler, prefer `throw error` over `throw new Error(error.message)` to preserve the stack for diagnosis."],"tags":["ipc","snapshot","ui-state","error-wrapping","serialization"],"backgroundTag":null,"analyzedSha":"9bdd81c7bdc57006e5f5ebffb79321a8d979f712","analyzedAt":"2026-08-13T04:09:25.751Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}