{"record":{"id":"988c045bd6e837d3","repo":"netbirdio/netbird","slug":"get-setup-key-v","errorCode":null,"errorMessage":"get setup key: %v","messagePattern":"get setup key: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/cmd/up.go","lineNumber":343,"sourceCode":"\t\tif st, ok := gstatus.FromError(err); ok && st.Code() == codes.Unavailable {\n\t\t\tlog.Warnf(\"setConfig method is not available in the daemon: %s\", st.Message())\n\t\t} else {\n\t\t\treturn daemonCallError(\"call service setConfig method\", err)\n\t\t}\n\t}\n\n\tif err := doDaemonUp(ctx, cmd, client, pm, activeProf, customDNSAddressConverted, username.Username); err != nil {\n\t\treturn fmt.Errorf(\"daemon up failed: %v\", err)\n\t}\n\tcmd.Println(\"Connected\")\n\treturn nil\n}\n\nfunc doDaemonUp(ctx context.Context, cmd *cobra.Command, client proto.DaemonServiceClient, pm *profilemanager.ProfileManager, activeProf *profilemanager.Profile, customDNSAddressConverted []byte, username string) error {\n\n\tprovidedSetupKey, err := getSetupKey()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"get setup key: %v\", err)\n\t}\n\n\tloginRequest, err := setupLoginRequest(providedSetupKey, customDNSAddressConverted, cmd)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"setup login request: %v\", err)\n\t}\n\n\tprofileID := activeProf.ID.String()\n\tloginRequest.ProfileName = &profileID\n\tloginRequest.Username = &username\n\n\tprofileState, err := pm.GetProfileState(activeProf.ID)\n\tif err != nil {\n\t\tlog.Debugf(\"failed to get profile state for login hint: %v\", err)\n\t} else if profileState.Email != \"\" {\n\t\tloginRequest.Hint = &profileState.Email\n\t}\n","sourceCodeStart":325,"sourceCodeEnd":361,"githubUrl":"https://github.com/netbirdio/netbird/blob/93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c/client/cmd/up.go#L325-L361","documentation":"Raised inside doDaemonUp when reading the setup key fails. getSetupKey prefers --setup-key; when that is empty and --setup-key-file is set, it reads the file and trims whitespace. The error here wraps a file read failure (the inner message is 'failed to read setup key file: ...'), e.g. missing file or permission denied.","triggerScenarios":"`netbird up --setup-key-file /path/key` where the path does not exist, is a directory, or is unreadable by the invoking user. Not triggered when --setup-key is also given (that flag wins) or neither flag is set.","commonSituations":"Secrets injected at a path that changed (e.g. Docker secret mounted elsewhere), typo in the path, file owned by root but CLI run as a normal user, or a systemd unit with a wrong WorkingDirectory-relative path.","solutions":["Verify the file exists and is readable: `ls -l <path>` and `cat <path>` as the same user","Fix the path, or pass the key directly with --setup-key (the flags are mutually exclusive)","For containers, confirm the secret/volume is mounted at the path passed to the flag"],"exampleFix":"# before\nnetbird up --setup-key-file /etc/netbird/setup-key\n# after\nnetbird up --setup-key-file /run/secrets/netbird-setup-key  # correct mount point","handlingStrategy":"validation","validationCode":"// before running up, check the file the flag will point at\nif setupKeyFile != \"\" {\n\tinfo, err := os.Stat(setupKeyFile)\n\tif err != nil || info.IsDir() {\n\t\treturn fmt.Errorf(\"setup key file unusable: %v\", err)\n\t}\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use absolute paths for --setup-key-file; do not rely on working directory","Mount secrets read-only at a fixed path in containers","Prefer --setup-key or an env-fed value in orchestration to avoid file-permission drift"],"tags":["go","netbird","cli","setup-key","file-io","secrets"],"backgroundTag":null,"analyzedSha":"93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c","analyzedAt":"2026-08-16T03:09:19.136Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}