{"record":{"id":"e29f3c100e32f73b","repo":"golangci/golangci-lint","slug":"missing-config-argument-in-constructor","errorCode":null,"errorMessage":"missing config argument in constructor","messagePattern":"missing config argument in constructor","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/printers/printer.go","lineNumber":47,"sourceCode":"// Printer prints issues.\ntype Printer struct {\n\tcfg        *config.Formats\n\treportData *report.Data\n\tbasePath   string\n\n\tlog logutils.Log\n\n\tstdOut io.Writer\n\tstdErr io.Writer\n}\n\n// NewPrinter creates a new Printer.\nfunc NewPrinter(log logutils.Log, cfg *config.Formats, reportData *report.Data, basePath string) (*Printer, error) {\n\tif log == nil {\n\t\treturn nil, errors.New(\"missing log argument in constructor\")\n\t}\n\tif cfg == nil {\n\t\treturn nil, errors.New(\"missing config argument in constructor\")\n\t}\n\tif reportData == nil {\n\t\treturn nil, errors.New(\"missing reportData argument in constructor\")\n\t}\n\n\treturn &Printer{\n\t\tcfg:        cfg,\n\t\treportData: reportData,\n\t\tbasePath:   basePath,\n\t\tlog:        log,\n\t\tstdOut:     logutils.StdOut,\n\t\tstdErr:     logutils.StdErr,\n\t}, nil\n}\n\n// Print prints issues based on the formats defined.\n//\n//nolint:gocyclo,funlen // the complexity is related to the number of formats.","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/golangci/golangci-lint/blob/ed7a235d2d771152056fdc142a9855567c5796a9/pkg/printers/printer.go#L29-L65","documentation":"Programmer-guard inside NewPrinter: the cfg parameter (*config.Formats) was nil. This is a defensive constructor check, not a user-facing config error — the caller (typically the run command wiring) passed an invalid argument.","triggerScenarios":"Thrown at pkg/printers/printer.go:47 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure callers construct a valid *config.Formats before calling NewPrinter","Fix the calling code to pass the loaded formats configuration"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"ed7a235d2d771152056fdc142a9855567c5796a9","analyzedAt":"2026-09-02T18:47:33.865Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}