{"record":{"id":"e205a501e6e88ded","repo":"microsoft/typescript-go","slug":"found-unusedbaselines-length-unused-baseline-fi","errorCode":null,"errorMessage":"Found ${unusedBaselines.length} unused baseline file(s). Run 'hereby baseline-accept' to delete them.","messagePattern":"Found (.+?) unused baseline file\\(s\\)\\. Run 'hereby baseline-accept' to delete them\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"Herebyfile.mjs","lineNumber":765,"sourceCode":"            const unusedBaselines = await checkUnusedBaselines(trackingDir);\r\n            if (unusedBaselines.length > 0) {\r\n                console.error(pc.red(`\\nFound ${unusedBaselines.length} unused baseline file(s):`));\r\n                for (const baseline of unusedBaselines.slice(0, 20)) {\r\n                    console.error(pc.red(`  ${baseline}`));\r\n                }\r\n                if (unusedBaselines.length > 20) {\r\n                    console.error(pc.red(`  ... and ${unusedBaselines.length - 20} more`));\r\n                }\r\n\r\n                // Create .delete files for each unused baseline so baseline-accept can remove them\r\n                for (const baseline of unusedBaselines) {\r\n                    const deleteFilePath = path.join(localBaseline, baseline + \".delete\");\r\n                    await fs.promises.mkdir(path.dirname(deleteFilePath), { recursive: true });\r\n                    await fs.promises.writeFile(deleteFilePath, \"\");\r\n                }\r\n                console.error(pc.red(`\\nRun 'hereby baseline-accept' to delete them.`));\r\n\r\n                throw new Error(`Found ${unusedBaselines.length} unused baseline file(s). Run 'hereby baseline-accept' to delete them.`);\r\n            }\r\n        }\r\n    }\r\n    finally {\r\n        if (cleanupTracking) {\r\n            cleanupTracking();\r\n        }\r\n    }\r\n}\r\n\r\nexport const test = task({\r\n    name: \"test\",\r\n    description: \"Runs all tests. This is the most typical test task to need.\",\r\n    run: runTests,\r\n});\r\n\r\nasync function runTestBenchmarks() {\r\n    warnIfTypeScriptSubmoduleNotCloned();\r","sourceCodeStart":747,"sourceCodeEnd":783,"githubUrl":"https://github.com/microsoft/typescript-go/blob/1bcfa18d79a3be41772223d5c05dfe4480e614ff/Herebyfile.mjs#L747-L783","documentation":"StopTracing serializes the legend (the mapping of per-checker types_*.json files, sorted by TypesPath) with json.MarshalIndent before writing legend.json. This error wraps a marshal failure of []TraceRecord — which for plain string/path fields is essentially unreachable in practice; it exists as a defensive wrap. It would only fire if a TraceRecord ever carried a value the encoder rejects (unsupported type, or a custom Marshaler returning an error).","triggerScenarios":"Calling StopTracing after a legend entry was populated with a field value json.MarshalIndent cannot encode: a NaN/Inf where a number is expected, a func/chan-typed value, or a type implementing json.Marshaler whose MarshalJSON errors. With the current TraceRecord (path strings), no realistic input triggers it; it mostly guards future field additions.","commonSituations":"Almost never seen in the field. Theoretically after refactors that add richer Args/metadata to TraceRecord; a custom JSON shim rejecting a value type.","solutions":["If you maintain tsgo and just hit this, inspect the TraceRecord fields you added — one holds a value the encoder can't serialize (func, chan, NaN/Inf float).","Coerce such values to strings or *float64 with NaN omitted before appending to tr.legend.","For library users: report it upstream — with stock TraceRecord this indicates a build mismatch or patched tree."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := tr.StopTracing(); err != nil {\n\tif strings.Contains(err.Error(), \"failed to marshal legend file\") {\n\t\t// marshal-side defect, not I/O: report with tracing config; trace/types files may still be intact\n\t\tlog.Printf(\"legend marshal failed (report upstream): %v\", err)\n\t}\n}","preventionTips":["Keep TraceRecord fields limited to JSON-encodable scalars when extending tsgo.","Cover legend serialization in unit tests after touching TraceRecord.","If hit as a user, capture the tsgo version and repro — stock builds should never produce this."],"tags":["tracing","json","serialization","defensive"],"backgroundTag":null,"analyzedSha":"1bcfa18d79a3be41772223d5c05dfe4480e614ff","analyzedAt":"2026-08-16T02:12:00.115Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}