{"record":{"id":"a1b6dfc847ee6d28","repo":"gofr-dev/gofr","slug":"invalid-azure-configuration-share-name-is-require","errorCode":null,"errorMessage":"invalid Azure configuration: share name is required","messagePattern":"invalid Azure configuration: share name is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/gofr/datasource/file/azure/fs.go","lineNumber":12,"sourceCode":"package azure\n\nimport (\n\t\"context\"\n\t\"errors\"\n\t\"time\"\n\n\t\"gofr.dev/pkg/gofr/datasource/file\"\n)\n\nvar (\n\terrInvalidConfig       = errors.New(\"invalid Azure configuration: share name is required\")\n\terrAccountNameRequired = errors.New(\"invalid Azure configuration: account name is required\")\n\terrAccountKeyRequired  = errors.New(\"invalid Azure configuration: account key is required\")\n)\n\nconst defaultTimeout = 10 * time.Second\n\ntype azureFileSystem struct {\n\t*file.CommonFileSystem\n}\n\n// Config represents the Azure File Storage configuration.\ntype Config struct {\n\tAccountName string // Azure Storage Account name\n\tAccountKey  string // Azure Storage Account key\n\tShareName   string // Azure File Share name\n\tEndpoint    string // Azure Storage endpoint (optional, defaults to core.windows.net)\n}\n","sourceCodeStart":1,"sourceCodeEnd":30,"githubUrl":"https://github.com/gofr-dev/gofr/blob/187eb24962502e91f1fee856230670958b66e89c/pkg/gofr/datasource/file/azure/fs.go#L1-L30","documentation":"azure.New validates its Azure Files configuration before building a client. If the Config's ShareName is empty, it returns the sentinel errInvalidConfig — \"invalid Azure configuration: share name is required\". All Azure Files operations target a share, so an empty share name makes the filesystem unusable and the library fails fast at construction instead of erroring on every later call.","triggerScenarios":"Calling azure.New(nil-config or config) where cfg.ShareName == \"\" — e.g. azure.New(nil), a FileSystem config struct built without setting ShareName, or ShareName sourced from an unset/empty environment variable.","commonSituations":"Missing AZURE_FILES_SHARE_NAME env var in deployment; config struct fields populated in the wrong order; copy-pasted config where the share key was renamed; tests constructing bare &file.FileSystem{} without ShareName.","solutions":["Set ShareName on the Config passed to azure.New (e.g. cfg.ShareName = \"my-share\" or via the environment variable the app maps from).","Verify the environment variable feeding ShareName is actually set in the deployment (kubectl describe pod / .env file).","Ensure azure.New receives a non-nil *Config — nil config also fails validation.","Add a startup-time validation in your own code to fail deployment early with a clear message."],"exampleFix":"// before\nfs := azure.New(nil)\n// after\ncfg := &Config{ShareName: os.Getenv(\"AZURE_SHARE\"), AccountName: acc, AccountKey: key}\nif cfg.ShareName == \"\" {\n    log.Fatal(\"AZURE_SHARE env var must be set\")\n}\nfs := azure.New(cfg)","handlingStrategy":"validation","validationCode":"cfg := azure.New(nil) // never — validate first\nfunc validateAzureConfig(cfg *azure.Config) error {\n    if cfg == nil || cfg.ShareName == \"\" {\n        return errors.New(\"azure share name must be configured\")\n    }\n    return nil\n}","typeGuard":"func azureConfigValid(cfg *azure.Config) bool {\n    return cfg != nil && cfg.ShareName != \"\" && cfg.AccountName != \"\" && cfg.AccountKey != \"\"\n}","tryCatchPattern":"fs := azure.New(cfg)\nif errors.Is(fs, errInvalidConfig) /* or err != nil check at New */ {\n    log.Fatal(\"azure share name missing — check AZURE share config\")\n}","preventionTips":["Validate all azure Config fields (ShareName, AccountName, AccountKey) at application startup.","Fail deployments fast with a config preflight check.","Keep share names in one config source; avoid scattering env lookups."],"tags":["azure","configuration","azure-files","missing-config"],"backgroundTag":"missing-config-field","analyzedSha":"187eb24962502e91f1fee856230670958b66e89c","analyzedAt":"2026-09-01T20:34:54.554Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}