go-kratos/kratos · error
fileNames invalid
Error message
fileNames invalid
What it means
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.
Source
Thrown at contrib/polaris/polaris.go:65
namespace: "default",
}
for _, option := range opts {
option(&op)
}
return op
}
func (p *Polaris) Config(opts ...ConfigOption) (config.Source, error) {
options := &configOptions{
namespace: p.namespace,
}
for _, opt := range opts {
opt(options)
}
if len(options.files) == 0 {
return nil, errors.New("fileNames invalid")
}
return &source{
client: p.config,
options: options,
}, nil
}
func (p *Polaris) Registry(opts ...RegistryOption) (r *Registry) {
op := registryOptions{
Namespace: p.namespace,
Healthy: true,
}
for _, option := range opts {
option(&op)
}
return &Registry{
opt: op,View on GitHub (pinned to 668db92c2c)
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
Example fix
// before
src, err := p.Config() // p := polaris.New(sdkCtx)
// err = fileNames invalid
// after
src, err := p.Config(
polaris.WithConfigFile(
polaris.File{Name: "config.yaml", Group: "myapp"},
polaris.File{Name: "feature.yaml", Group: "myapp"},
),
) Defensive patterns
Strategy: validation
Validate before calling
files := []polaris.File{{Name: "config.yaml", Group: "myapp"}}
if len(files) == 0 {
return fmt.Errorf("polaris.Config requires at least one WithConfigFile entry")
}
src, err := p.Config(polaris.WithConfigFile(files...)) Prevention
- 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
When it happens
Trigger: 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"}, ...)).
Common situations: 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).
Related errors
AI-assisted analysis of go-kratos/kratos@668db92c2c (2026-08-16).
Data as JSON: /api/errors/94c2faba48c405f6.
Report an issue: GitHub.