{"record":{"id":"bb8cca3104bfc012","repo":"apache/beam","slug":"must-supply-dot-file-argument","errorCode":null,"errorMessage":"must supply dot_file argument","messagePattern":"must supply dot_file argument","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/runners/dot/dot.go","lineNumber":42,"sourceCode":"\t\"os\"\n\n\t\"github.com/apache/beam/sdks/v2/go/pkg/beam\"\n\tdotlib \"github.com/apache/beam/sdks/v2/go/pkg/beam/core/util/dot\"\n\t\"github.com/apache/beam/sdks/v2/go/pkg/beam/internal/errors\"\n)\n\nfunc init() {\n\tbeam.RegisterRunner(\"dot\", Execute)\n}\n\n// Code for making DOT graphs of the Graph data structure\n\nvar dotFile = flag.String(\"dot_file\", \"\", \"DOT output file to create\")\n\n// Execute produces a DOT representation of the pipeline.\nfunc Execute(ctx context.Context, p *beam.Pipeline) (beam.PipelineResult, error) {\n\tif *dotFile == \"\" {\n\t\treturn nil, errors.New(\"must supply dot_file argument\")\n\t}\n\n\tedges, nodes, err := p.Build()\n\tif err != nil {\n\t\treturn nil, errors.New(\"can't get data to render\")\n\t}\n\n\tvar buf bytes.Buffer\n\tif err := dotlib.Render(edges, nodes, &buf); err != nil {\n\t\treturn nil, err\n\t}\n\treturn nil, os.WriteFile(*dotFile, buf.Bytes(), 0644)\n}\n","sourceCodeStart":24,"sourceCodeEnd":56,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/runners/dot/dot.go#L24-L56","documentation":"The dot runner's Execute produces a DOT graph of the pipeline and writes it to the file given by the required --dot_file flag. If the flag was not supplied (empty string), it returns this error before building the pipeline. The runner has no meaningful default output path.","triggerScenarios":"Running a pipeline with the dot runner without passing --dot_file=<path>, or invoking beam.Execute with the dot runner registered but the dotFile flag never set (e.g. calling Execute programmatically without flag.Parse).","commonSituations":"Forgetting the --dot_file flag on the command line; setting up the dot runner in tests without initializing flags (no flag.Parse() call); empty value passed as --dot_file=\"\".","solutions":["Pass --dot_file=graph.dot (a writable path) on the command line.","If invoking programmatically, ensure flag.Parse() runs or set *dotFile (or use flag.Set(\"dot_file\", \"graph.dot\")) before Execute.","Check that the value is non-empty and the directory is writable."],"exampleFix":"// before\n// go run ./pipeline --runner=dot\n// after\n// go run ./pipeline --runner=dot --dot_file=out/graph.dot","handlingStrategy":"validation","validationCode":"if *dotFile == \"\" {\n    return errors.New(\"--dot_file is required for the dot runner; pass --dot_file=graph.dot\")\n}","typeGuard":null,"tryCatchPattern":"if _, err := beam.Execute(ctx, p); err != nil && strings.Contains(err.Error(), \"dot_file\") {\n    // re-run with the flag or set flag.Set(\"dot_file\", \"graph.dot\") before Execute\n}","preventionTips":["Always pass --dot_file when using the dot runner.","Call flag.Parse() before Execute when invoking programmatically.","Wrap the dot runner in a launcher that supplies a default output path.","Verify the target directory exists and is writable to avoid the follow-on write failure."],"tags":["beam","dot","cli","missing-flag"],"backgroundTag":"missing-required-flag","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T21:17:11.552Z"}