{"record":{"id":"3a3c5a9de8297003","repo":"microsoft/typescript-go","slug":"failed-to-marshal-legend-file-w","errorCode":null,"errorMessage":"failed to marshal legend file: %w","messagePattern":"failed to marshal legend file: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/tracing/tracing.go","lineNumber":475,"sourceCode":"\t\t}\n\t\t// Flush any remaining buffered content and close the JSON array.\n\t\tif err := tr.fs.AppendFile(tr.tracePath, tr.traceContent.String()+\"\\n]\\n\"); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to write trace file: %w\", err)\n\t\t}\n\t\ttr.traceContent.Reset()\n\t\ttr.traceStarted.Store(false)\n\t}\n\n\t// Sort legend entries by typesPath for deterministic output\n\tslices.SortFunc(tr.legend, func(a, b TraceRecord) int {\n\t\treturn strings.Compare(a.TypesPath, b.TypesPath)\n\t})\n\n\t// Write the legend file\n\tlegendPath := tspath.CombinePaths(tr.traceDir, \"legend.json\")\n\tlegendData, err := json.MarshalIndent(tr.legend, \"\", \"  \")\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to marshal legend file: %w\", err)\n\t}\n\tif err := tr.fs.WriteFile(legendPath, string(legendData)); err != nil {\n\t\treturn fmt.Errorf(\"failed to write legend file: %w\", err)\n\t}\n\n\treturn nil\n}\n\n// typeTracer is the per-checker tracer implementation\ntype typeTracer struct {\n\tfs           vfs.FS\n\tcheckerIndex int\n\ttypesPath    string\n\ttypes        []TracedType\n\tmu           sync.Mutex\n}\n\nfunc (t *typeTracer) RecordType(typ TracedType) {","sourceCodeStart":457,"sourceCodeEnd":493,"githubUrl":"https://github.com/microsoft/typescript-go/blob/1bcfa18d79a3be41772223d5c05dfe4480e614ff/internal/tracing/tracing.go#L457-L493","documentation":"Error \"failed to marshal legend file: %w\" thrown in microsoft/typescript-go.","triggerScenarios":"Thrown at internal/tracing/tracing.go:475 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"1bcfa18d79a3be41772223d5c05dfe4480e614ff","analyzedAt":"2026-08-16T02:12:00.115Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}