{"record":{"id":"f262f6330c7f2ef0","repo":"toeverything/AFFiNE","slug":"invalid-label","errorCode":null,"errorMessage":"Invalid ${label}","messagePattern":"Invalid (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/frontend/apps/electron/src/shared/utils.ts","lineNumber":140,"sourceCode":"  return resolvedTarget;\n}\n\nexport function assertPathComponent(\n  value: string,\n  label: string = 'path component'\n) {\n  const hasControlChar = Array.from(value).some(\n    character => character.charCodeAt(0) < 0x20\n  );\n\n  if (\n    !value ||\n    value === '.' ||\n    value === '..' ||\n    /[/\\\\]/.test(value) ||\n    hasControlChar\n  ) {\n    throw new Error(`Invalid ${label}`);\n  }\n\n  return value;\n}\n\nexport function normalizeWorkspaceIdForPath(\n  value: string,\n  options: { windows?: boolean; label?: string } = {}\n) {\n  const { windows = isWindows(), label = 'workspace id' } = options;\n  const safeValue = assertPathComponent(value, label);\n\n  if (!windows) {\n    return safeValue;\n  }\n\n  const windowsReservedChars = new Set(['<', '>', ':', '\"', '|', '?', '*']);\n  let normalized = '';","sourceCodeStart":122,"sourceCodeEnd":158,"githubUrl":"https://github.com/toeverything/AFFiNE/blob/b4c8548c09da21b2898443559a5b846f0ccf5dd8/packages/frontend/apps/electron/src/shared/utils.ts#L122-L158","documentation":"assertPathComponent rejects empty values, dot segments, path separators, and control characters, throwing 'Invalid <label>' so a single unsanitized path component cannot inject directory traversal into paths.","triggerScenarios":"Thrown at packages/frontend/apps/electron/src/shared/utils.ts:140 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass a valid value for the labeled field named in the error.","Check the IPC payload from the renderer for missing or wrong-typed values.","Validate the input on the caller side before invoking the Electron API."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"b4c8548c09da21b2898443559a5b846f0ccf5dd8","analyzedAt":"2026-08-18T21:16:52.546Z","contentChangedAt":"2026-08-18T21:16:52.546Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}