{"record":{"id":"5979adc34bcaf154","repo":"jackwener/OpenCLI","slug":"failed-to-parse-extensions-json-e-message","errorCode":null,"errorMessage":"Failed to parse extensions.json: ${e.message}","messagePattern":"Failed to parse extensions\\.json: (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/trae-solo/workspaces-fs.js","lineNumber":92,"sourceCode":"    access: 'read',\n    description: 'List VSCode extensions installed in Trae SOLO (~/.trae/extensions/extensions.json). Works while Trae is closed.',\n    domain: 'localhost',\n    browser: false,\n    strategy: Strategy.LOCAL,\n    args: [],\n    columns: ['Index', 'Workspace Id', 'Kind', 'Target', 'Modified', 'Id', 'Version', 'Source', 'Installed'],\n    func: async () => {\n        if (!fs.existsSync(TRAE_EXTENSIONS_JSON)) {\n            throw new CommandExecutionError(\n                `extensions.json not found: ${TRAE_EXTENSIONS_JSON}`,\n                'Trae SOLO has not installed any VSCode extensions yet.',\n            );\n        }\n        let arr;\n        try {\n            arr = JSON.parse(fs.readFileSync(TRAE_EXTENSIONS_JSON, 'utf-8'));\n        } catch (e) {\n            throw new CommandExecutionError(`Failed to parse extensions.json: ${e.message}`, '');\n        }\n        if (!Array.isArray(arr) || !arr.length) {\n            throw new EmptyResultError('trae-solo extensions-list', 'No extensions installed.');\n        }\n        return arr.map((e, i) => {\n            const ts = e?.metadata?.installedTimestamp;\n            const installed = ts ? new Date(ts).toISOString().replace('T', ' ').slice(0, 19) : '';\n            return {\n                Index: i + 1,\n                'Workspace Id': '',\n                Kind: '',\n                Target: '',\n                Modified: '',\n                Id: e?.identifier?.id || '?',\n                Version: e?.version || '',\n                Source: e?.metadata?.source || '',\n                Installed: installed,\n            };","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/trae-solo/workspaces-fs.js#L74-L110","documentation":"This CommandExecutionError is thrown by the extensions-list command when TRAE_EXTENSIONS_JSON exists but JSON.parse fails on its contents. The caught SyntaxError message is embedded in the error so the developer can see the exact parse failure (position, unexpected token, etc.).","triggerScenarios":"extensions.json truncated by an interrupted write or crash mid-save; the file contains comments or a JSONC-style format strict JSON.parse rejects; encoding issues (BOM, invalid UTF-8); the file was hand-edited with a syntax mistake.","commonSituations":"Machine or Trae killed while extensions.json was being rewritten; tooling or a user manually edited the file; another process wrote it in a slightly different format; disk-full corruption.","solutions":["Inspect extensions.json with a JSON validator and fix the syntax error at the reported position","Restore the file from backup, or back it up and delete it, then reinstall extensions to regenerate it","If the file is JSONC (comments), strip comments before parsing or use a JSONC-aware parser","Close Trae, verify file integrity, and reopen so Trae rewrites the file cleanly"],"exampleFix":"// before\ntry {\n    arr = JSON.parse(fs.readFileSync(TRAE_EXTENSIONS_JSON, 'utf-8'));\n} catch (e) {\n    throw new CommandExecutionError(`Failed to parse extensions.json: ${e.message}`, '');\n}\n// after\nconst text = fs.readFileSync(TRAE_EXTENSIONS_JSON, 'utf-8').replace(/^\\uFEFF/, '');\nlet arr;\ntry {\n    arr = JSON.parse(text);\n} catch (e) {\n    console.error(`extensions.json corrupt (${e.message}); backing up, treating as empty`);\n    fs.copyFileSync(TRAE_EXTENSIONS_JSON, TRAE_EXTENSIONS_JSON + '.bak');\n    arr = [];\n}","handlingStrategy":"try-catch","validationCode":"const text = fs.readFileSync(TRAE_EXTENSIONS_JSON, 'utf-8').replace(/^\\uFEFF/, '');\ntry { JSON.parse(text); } catch (e) {\n    console.warn(`extensions.json is invalid JSON: ${e.message}`);\n}","typeGuard":null,"tryCatchPattern":"try {\n    const rows = await runExtensionsList();\n} catch (e) {\n    if (/Failed to parse extensions\\.json/.test(e.message)) {\n        console.warn(`${e.message}; restore extensions.json from backup or reinstall extensions.`);\n        return [];\n    }\n    throw e;\n}","preventionTips":["Never hand-edit extensions.json while Trae is running","Validate the file with a JSON linter after manual edits","Back up extensions.json before Trae upgrades or bulk extension operations","Strip a leading BOM before parsing","Check disk space to avoid truncated writes"],"tags":["json","parse-error","corruption"],"backgroundTag":"json-parse-error","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}