{"record":{"id":"30961cc4a5f37edc","repo":"golangci/golangci-lint","slug":"config-is-disabled-by-no-config","errorCode":null,"errorMessage":"config is disabled by --no-config","messagePattern":"config is disabled by --no-config","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"info","filePath":"pkg/config/loader.go","lineNumber":18,"sourceCode":"package config\n\nimport (\n\t\"context\"\n\t\"errors\"\n\t\"fmt\"\n\t\"os\"\n\t\"slices\"\n\n\t\"github.com/spf13/pflag\"\n\t\"github.com/spf13/viper\"\n\n\t\"github.com/golangci/golangci-lint/v2/pkg/fsutils\"\n\t\"github.com/golangci/golangci-lint/v2/pkg/goutil\"\n\t\"github.com/golangci/golangci-lint/v2/pkg/logutils\"\n)\n\nvar errConfigDisabled = errors.New(\"config is disabled by --no-config\")\n\nconst (\n\tmodeLinters    = \"linters\"\n\tmodeFormatters = \"formatters\"\n)\n\ntype LoaderOptions struct {\n\tConfig   string // Flag only. The path to the golangci config file, as specified with the --config argument.\n\tNoConfig bool   // Flag only.\n}\n\ntype LoadOptions struct {\n\tCheckDeprecation bool\n\tValidation       bool\n}\n\ntype Loader struct {\n\t*BaseLoader","sourceCodeStart":1,"sourceCodeEnd":36,"githubUrl":"https://github.com/golangci/golangci-lint/blob/ed7a235d2d771152056fdc142a9855567c5796a9/pkg/config/loader.go#L1-L36","documentation":"errConfigDisabled is the sentinel error (declared in loader.go) returned by evaluateOptions/setConfigFile when --no-config is set. It is not a failure: callers check errors.Is(err, errConfigDisabled) and silently skip config loading, meaning the run proceeds with default settings.","triggerScenarios":"Running golangci-lint with --no-config; the loader detects opts.NoConfig in evaluateOptions (base_loader.go:89) and setConfigFile treats it as a normal early-exit at base_loader.go:62.","commonSituations":"Intentionally running with defaults in CI; users confused why their .golangci.yml seems ignored — because --no-config suppressed it entirely.","solutions":["Remove the --no-config flag to load .golangci.yml again.","Use --config <file> to load a specific config even from another directory.","In code, treat errors.Is(err, errConfigDisabled) as a non-fatal condition, matching the loader's own handling."],"exampleFix":"// before\nif err := l.Load(target); err != nil { return err } // treats no-config as failure\n\n// after\nif err := l.Load(target); err != nil && !errors.Is(err, errConfigDisabled) { return err }","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"err := loader.Load(target)\nif err != nil && !errors.Is(err, errConfigDisabled) {\n    return fmt.Errorf(\"loading config: %w\", err)\n}\n// errConfigDisabled means defaults are in use; not fatal.","preventionTips":["Only pass --no-config when you truly want defaults; remember it hides all config files.","Treat this sentinel as a normal early-exit via errors.Is, never as a hard failure.","Document in team scripts why --no-config is used so it isn't copied blindly."],"tags":["configuration","cli","sentinel-error"],"backgroundTag":"config-disabled-by-flag","analyzedSha":"ed7a235d2d771152056fdc142a9855567c5796a9","analyzedAt":"2026-09-02T18:47:33.865Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}