go-kratos/kratos · error
fileGroup invalid
Error message
fileGroup invalid
What it means
Returned by the polaris config source constructor (contrib/config/polaris/config.go:63). New(client) defaults fileGroup:"" and the WithFileGroup option is the only setter; a polaris config file is addressed by (namespace, fileGroup, fileName), so without a file group the source cannot address anything and New fails.
Source
Thrown at contrib/config/polaris/config.go:63
type source struct {
client polaris.ConfigAPI
options *options
}
func New(client polaris.ConfigAPI, opts ...Option) (config.Source, error) {
options := &options{
namespace: "default",
fileGroup: "",
fileName: "",
}
for _, opt := range opts {
opt(options)
}
if options.fileGroup == "" {
return nil, errors.New("fileGroup invalid")
}
if options.fileName == "" {
return nil, errors.New("fileName invalid")
}
return &source{
client: client,
options: options,
}, nil
}
// Load return the config values
func (s *source) Load() ([]*config.KeyValue, error) {
configFile, err := s.client.FetchConfigFile(&polaris.GetConfigFileRequest{
GetConfigFileRequest: &model.GetConfigFileRequest{
Namespace: s.options.namespace,
FileGroup: s.options.fileGroup,View on GitHub (pinned to 668db92c2c)
Solutions
- Pass polarisConfig.WithFileGroup matching the group created in the polaris console, e.g. polarisConfig.New(cli, polarisConfig.WithNamespace("default"), polarisConfig.WithFileGroup("mygroup"), polarisConfig.WithFileName("config.yaml"))
- Verify the group exists in the polaris console under the same namespace
Example fix
// before
src, err := polarisConfig.New(cli)
// err = fileGroup invalid
// after
src, err := polarisConfig.New(cli,
polarisConfig.WithNamespace("default"),
polarisConfig.WithFileGroup("myapp"),
polarisConfig.WithFileName("config.yaml"),
) Defensive patterns
Strategy: validation
Validate before calling
if fileGroup == "" || fileName == "" {
return fmt.Errorf("polaris config requires fileGroup and fileName")
}
src, err := polarisConfig.New(cli,
polarisConfig.WithNamespace(ns),
polarisConfig.WithFileGroup(fileGroup),
polarisConfig.WithFileName(fileName),
) Prevention
- Create the group+file in the polaris console first, then mirror both names into options
- Validate required option fields at app bootstrap before constructing sources
- Keep namespace/group/file names in one struct so they are set together
When it happens
Trigger: Calling config source constructor as polarisConfig.New(polarisConfigClient) with no options, or passing only WithNamespace/WithFileName. Every valid call needs polarisConfig.WithFileGroup("...") (and WithFileName, which is checked next at line 67).
Common situations: Porting the polaris registry usage to config usage and missing that config requires the extra group/file options; creating the file group in the polaris console but forgetting to pass its name; option typo so Go treats it as an unknown field rather than the real option.
Related errors
AI-assisted analysis of go-kratos/kratos@668db92c2c (2026-08-16).
Data as JSON: /api/errors/4eb42673695b6a52.
Report an issue: GitHub.