{"record":{"id":"4eb42673695b6a52","repo":"go-kratos/kratos","slug":"filegroup-invalid","errorCode":null,"errorMessage":"fileGroup invalid","messagePattern":"fileGroup invalid","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"contrib/config/polaris/config.go","lineNumber":63,"sourceCode":"\ntype source struct {\n\tclient  polaris.ConfigAPI\n\toptions *options\n}\n\nfunc New(client polaris.ConfigAPI, opts ...Option) (config.Source, error) {\n\toptions := &options{\n\t\tnamespace: \"default\",\n\t\tfileGroup: \"\",\n\t\tfileName:  \"\",\n\t}\n\n\tfor _, opt := range opts {\n\t\topt(options)\n\t}\n\n\tif options.fileGroup == \"\" {\n\t\treturn nil, errors.New(\"fileGroup invalid\")\n\t}\n\n\tif options.fileName == \"\" {\n\t\treturn nil, errors.New(\"fileName invalid\")\n\t}\n\n\treturn &source{\n\t\tclient:  client,\n\t\toptions: options,\n\t}, nil\n}\n\n// Load return the config values\nfunc (s *source) Load() ([]*config.KeyValue, error) {\n\tconfigFile, err := s.client.FetchConfigFile(&polaris.GetConfigFileRequest{\n\t\tGetConfigFileRequest: &model.GetConfigFileRequest{\n\t\t\tNamespace: s.options.namespace,\n\t\t\tFileGroup: s.options.fileGroup,","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/go-kratos/kratos/blob/668db92c2c001e9552594ba5a8aede8456af6d7e/contrib/config/polaris/config.go#L45-L81","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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"],"exampleFix":"// before\nsrc, err := polarisConfig.New(cli)\n// err = fileGroup invalid\n\n// after\nsrc, err := polarisConfig.New(cli,\n    polarisConfig.WithNamespace(\"default\"),\n    polarisConfig.WithFileGroup(\"myapp\"),\n    polarisConfig.WithFileName(\"config.yaml\"),\n)","handlingStrategy":"validation","validationCode":"if fileGroup == \"\" || fileName == \"\" {\n    return fmt.Errorf(\"polaris config requires fileGroup and fileName\")\n}\nsrc, err := polarisConfig.New(cli,\n    polarisConfig.WithNamespace(ns),\n    polarisConfig.WithFileGroup(fileGroup),\n    polarisConfig.WithFileName(fileName),\n)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["config","polaris","constructor-validation"],"backgroundTag":null,"analyzedSha":"668db92c2c001e9552594ba5a8aede8456af6d7e","analyzedAt":"2026-08-16T02:07:20.704Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}