{"record":{"id":"94c2faba48c405f6","repo":"go-kratos/kratos","slug":"filenames-invalid","errorCode":null,"errorMessage":"fileNames invalid","messagePattern":"fileNames invalid","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"contrib/polaris/polaris.go","lineNumber":65,"sourceCode":"\t\tnamespace: \"default\",\n\t}\n\tfor _, option := range opts {\n\t\toption(&op)\n\t}\n\treturn op\n}\n\nfunc (p *Polaris) Config(opts ...ConfigOption) (config.Source, error) {\n\toptions := &configOptions{\n\t\tnamespace: p.namespace,\n\t}\n\n\tfor _, opt := range opts {\n\t\topt(options)\n\t}\n\n\tif len(options.files) == 0 {\n\t\treturn nil, errors.New(\"fileNames invalid\")\n\t}\n\n\treturn &source{\n\t\tclient:  p.config,\n\t\toptions: options,\n\t}, nil\n}\n\nfunc (p *Polaris) Registry(opts ...RegistryOption) (r *Registry) {\n\top := registryOptions{\n\t\tNamespace: p.namespace,\n\t\tHealthy:   true,\n\t}\n\tfor _, option := range opts {\n\t\toption(&op)\n\t}\n\treturn &Registry{\n\t\topt:      op,","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/go-kratos/kratos/blob/668db92c2c001e9552594ba5a8aede8456af6d7e/contrib/polaris/polaris.go#L47-L83","documentation":"Returned by Polaris.Config in the polaris contrib facade (contrib/polaris/polaris.go:65). Unlike the standalone config source (which takes one group+file), this facade takes a list of File{Name,Group} structs via WithConfigFile and stores them in options.files; if the slice is empty there is nothing to fetch and Config returns this error. Note the different message ('fileNames', plural) versus the standalone package's singular checks.","triggerScenarios":"Calling p.Config() with no options on a Polaris value built by polaris.New(sdkCtx); or passing a variadic WithConfigFile() with zero arguments, which still leaves files empty. Every valid call is p.Config(polaris.WithConfigFile(polaris.File{Name: \"config.yaml\", Group: \"myapp\"}, ...)).","commonSituations":"Using the Polaris facade for registry/ratelimit and assuming Config() needs no arguments; passing WithConfigFile(nil) or an empty slice variable; option named similarly to the standalone package's WithFileName being used here by mistake (it does not exist on the facade).","solutions":["Pass at least one polaris.File via polaris.WithConfigFile, e.g. p.Config(polaris.WithConfigFile(polaris.File{Name: \"config.yaml\", Group: \"myapp\"}))","If you only need single-file config, prefer the standalone contrib/config/polaris package with WithFileGroup/WithFileName"],"exampleFix":"// before\nsrc, err := p.Config() // p := polaris.New(sdkCtx)\n// err = fileNames invalid\n\n// after\nsrc, err := p.Config(\n    polaris.WithConfigFile(\n        polaris.File{Name: \"config.yaml\", Group: \"myapp\"},\n        polaris.File{Name: \"feature.yaml\", Group: \"myapp\"},\n    ),\n)","handlingStrategy":"validation","validationCode":"files := []polaris.File{{Name: \"config.yaml\", Group: \"myapp\"}}\nif len(files) == 0 {\n    return fmt.Errorf(\"polaris.Config requires at least one WithConfigFile entry\")\n}\nsrc, err := p.Config(polaris.WithConfigFile(files...))","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Remember the facade API differs from the standalone package: WithConfigFile(File{...}) not WithFileGroup/WithFileName","Never call p.Config() bare; lint for zero-argument calls in config wiring","Prefer the standalone contrib/config/polaris package when only a single file is needed"],"tags":["config","polaris","facade","constructor-validation"],"backgroundTag":null,"analyzedSha":"668db92c2c001e9552594ba5a8aede8456af6d7e","analyzedAt":"2026-08-16T02:07:20.704Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}