{"record":{"id":"b5065871ec6150d5","repo":"netbirdio/netbird","slug":"create-config-w","errorCode":null,"errorMessage":"create config: %w","messagePattern":"create config: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/embed/embed.go","lineNumber":216,"sourceCode":"\t\tConfigPath:          opts.ConfigPath,\n\t\tManagementURL:       opts.ManagementURL,\n\t\tPreSharedKey:        &opts.PreSharedKey,\n\t\tDisableServerRoutes: &t,\n\t\tDisableClientRoutes: &opts.DisableClientRoutes,\n\t\tDisableIPv6:         &opts.DisableIPv6,\n\t\tBlockInbound:        &opts.BlockInbound,\n\t\tBlockLANAccess:      &opts.BlockLANAccess,\n\t\tWireguardPort:       opts.WireguardPort,\n\t\tMTU:                 opts.MTU,\n\t\tDNSLabels:           parsedLabels,\n\t}\n\tif opts.ConfigPath != \"\" {\n\t\tconfig, err = profilemanager.UpdateOrCreateConfig(input)\n\t} else {\n\t\tconfig, err = profilemanager.CreateInMemoryConfig(input)\n\t}\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"create config: %w\", err)\n\t}\n\n\tif opts.PrivateKey != \"\" {\n\t\tconfig.PrivateKey = opts.PrivateKey\n\t}\n\n\tif opts.Performance.PreallocatedBuffersPerPool != nil {\n\t\twgdevice.SetPreallocatedBuffersPerPool(*opts.Performance.PreallocatedBuffersPerPool)\n\t}\n\tif opts.Performance.MaxBatchSize != nil {\n\t\twgdevice.SetMaxBatchSizeOverride(*opts.Performance.MaxBatchSize)\n\t}\n\n\treturn &Client{\n\t\tdeviceName: opts.DeviceName,\n\t\tsetupKey:   opts.SetupKey,\n\t\tjwtToken:   opts.JWTToken,\n\t\tconfig:     config,","sourceCodeStart":198,"sourceCodeEnd":234,"githubUrl":"https://github.com/netbirdio/netbird/blob/93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c/client/embed/embed.go#L198-L234","documentation":"Returned by embed.New when the profile manager cannot produce a configuration: profilemanager.UpdateOrCreateConfig when Options.ConfigPath is set (load/update the JSON config file) or profilemanager.CreateInMemoryConfig otherwise. The wrapped error comes from parsing the existing config file, reading/writing the path, or normalizing fields such as the management URL or pre-shared key.","triggerScenarios":"embed.New with ConfigPath pointing to a missing directory, a corrupt or non-JSON existing config file, a file the process cannot read/write (permissions), or with an invalid ManagementURL / PreSharedKey that fails config normalization.","commonSituations":"Running the embedding binary without write access to the config location; a partially written config from a crashed previous run; a management URL copied with a typo or missing scheme; a pre-shared key in the wrong base64 format; switching ConfigPath between versions whose config schema changed.","solutions":["Check the wrapped error: file/permission problems point at ConfigPath, parse problems at the file content.","Ensure the ConfigPath directory exists and the process has read/write access, or delete the corrupt file to regenerate it.","Verify ManagementURL has a valid scheme+host and the PreSharedKey is a valid key string.","If you do not need persistence, leave ConfigPath empty to use the in-memory config path."],"exampleFix":"// before\nclient, err := embed.New(embed.Options{ConfigPath: \"/etc/netbird/embed.json\", ...})\n\n// after\nif err := os.MkdirAll(filepath.Dir(cfgPath), 0o700); err != nil { return err }\nclient, err := embed.New(embed.Options{ConfigPath: cfgPath, ...})","handlingStrategy":"validation","validationCode":"if opts.ConfigPath != \"\" {\n    if err := os.MkdirAll(filepath.Dir(opts.ConfigPath), 0o700); err != nil {\n        return err\n    }\n    if _, err := os.Stat(opts.ConfigPath); err == nil {\n        if data, rerr := os.ReadFile(opts.ConfigPath); rerr != nil || !json.Valid(data) {\n            return fmt.Errorf(\"existing config unreadable/corrupt: remove %s\", opts.ConfigPath)\n        }\n    }\n}","typeGuard":null,"tryCatchPattern":"client, err := embed.New(opts)\nif err != nil {\n    if strings.Contains(err.Error(), \"create config\") {\n        // decide: regenerate config from scratch (delete file) or surface to user\n    }\n}","preventionTips":["Write config files atomically (temp file + rename) in your own tooling to avoid corrupt files.","Validate ManagementURL with url.Parse and scheme check before passing it in Options."],"tags":["config","filesystem","embed"],"backgroundTag":null,"analyzedSha":"93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c","analyzedAt":"2026-08-16T03:09:19.136Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}