{"record":{"id":"83308f6da999830a","repo":"go-kratos/kratos","slug":"filename-invalid","errorCode":null,"errorMessage":"fileName invalid","messagePattern":"fileName invalid","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"contrib/config/polaris/config.go","lineNumber":67,"sourceCode":"}\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,\n\t\t\tFileName:  s.options.fileName,\n\t\t\tSubscribe: true,\n\t\t},\n\t})","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/go-kratos/kratos/blob/668db92c2c001e9552594ba5a8aede8456af6d7e/contrib/config/polaris/config.go#L49-L85","documentation":"Returned by the polaris config source constructor (contrib/config/polaris/config.go:67), immediately after the fileGroup check. options.fileName defaults to \"\" and only WithFileName sets it; a polaris config file is identified by (namespace, fileGroup, fileName), so an empty fileName makes the FetchConfigFile request in Load() unaddressable and New rejects it up front.","triggerScenarios":"Calling polarisConfig.New(cli, polarisConfig.WithFileGroup(\"mygroup\")) without WithFileName; or passing options in the wrong belief that fileName defaults from the client. Any construction where options.fileName is \"\" fails here.","commonSituations":"Only supplying the group after copying a half-finished example; renaming the file in the polaris console but not in code (an empty string is the extreme case); passing WithFileName(\"\") from an uninitialized variable.","solutions":["Add polarisConfig.WithFileName with the exact file name created in the polaris console, e.g. WithFileName(\"config.yaml\")","Check the polaris console that the file exists under the same namespace+group you configured"],"exampleFix":"// before\nsrc, err := polarisConfig.New(cli, polarisConfig.WithFileGroup(\"myapp\"))\n// err = fileName 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 fileName == \"\" {\n    return fmt.Errorf(\"polaris config requires fileName\")\n}\nsrc, err := polarisConfig.New(cli,\n    polarisConfig.WithFileGroup(fileGroup),\n    polarisConfig.WithFileName(fileName),\n)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Set WithFileGroup and WithFileName together - the constructor checks both in order","Exact-match the file name shown in the polaris console (case-sensitive)","Bind the names to config/env checked at startup, failing fast on empty values"],"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"}