{"record":{"id":"a3d7e2f7549b8cb5","repo":"golang/go","slug":"no-trace-file-supplied","errorCode":null,"errorMessage":"no trace file supplied","messagePattern":"no trace file supplied","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/go/internal/trace/trace.go","lineNumber":184,"sourceCode":"\nfunc (t *tracer) getNextFlowID() uint64 {\n\treturn t.nextFlowID.Add(1)\n}\n\n// traceKey is the context key for tracing information. It is unexported to prevent collisions with context keys defined in\n// other packages.\ntype traceKey struct{}\n\ntype traceContext struct {\n\tt   *tracer\n\ttid uint64\n}\n\n// Start starts a trace which writes to the given file.\nfunc Start(ctx context.Context, file string) (context.Context, func() error, error) {\n\ttraceStarted.Store(true)\n\tif file == \"\" {\n\t\treturn nil, nil, errors.New(\"no trace file supplied\")\n\t}\n\tf, err := os.Create(file)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\tt := &tracer{file: make(chan traceFile, 1)}\n\tsb := new(strings.Builder)\n\tt.file <- traceFile{\n\t\tf:   f,\n\t\tsb:  sb,\n\t\tenc: json.NewEncoder(sb),\n\t}\n\tctx = context.WithValue(ctx, traceKey{}, traceContext{t: t})\n\treturn ctx, t.Close, nil\n}\n\ntype traceFile struct {\n\tf       *os.File","sourceCodeStart":166,"sourceCodeEnd":202,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/trace/trace.go#L166-L202","documentation":"trace.Start requires a destination file path; passing an empty string is rejected up front. This is the entry point backing the `go trace` (trace viewer) command's file handling.","triggerScenarios":"Calling trace.Start(ctx, \"\") directly, or invoking the trace subcommand without supplying a trace file argument.","commonSituations":"Forgot the file argument; scripting that passes an empty path; mis-parsed CLI flags.","solutions":["Supply a non-empty file path to trace.Start / the trace subcommand.","Generate a trace first (runtime/trace.Start) if you don't have one yet."],"exampleFix":"// before\nctx, stop, err := trace.Start(context.Background(), \"\")\n\n// after\nctx, stop, err := trace.Start(context.Background(), \"./trace.out\")","handlingStrategy":"validation","validationCode":"// Reject an empty trace file before calling Start.\nfunc startTrace(file string) (context.Context, func() error, error) {\n    if file == \"\" { return nil, nil, errors.New(\"provide a trace file path\") }\n    return trace.Start(context.Background(), file)\n}","typeGuard":"null","tryCatchPattern":"null","preventionTips":["Always pass an explicit file argument to trace.Start.","Validate CLI args before forwarding them to library calls."],"tags":["trace","cli","validation"],"backgroundTag":null,"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}