netbirdio/netbird · error
failed to read setup key file
Error message
failed to read setup key file: %v
What it means
Reading the setup-key file failed inside getSetupKeyFromFile: --setup-key-file was given (with no inline --setup-key) but os.ReadFile could not read the path — nonexistent file, permission denied, or a directory.
Solutions
- Verify the path exists and is readable by the invoking user
- Use an absolute path to avoid working-directory ambiguity
- Alternatively pass the key inline with --setup-key
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at client/cmd/root.go:322 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of netbirdio/netbird@93e97f4bf1 (2026-08-16).
Data as JSON: /api/errors/5ba42e14f0aa5e83.
Report an issue: GitHub.
Appendix: source
Thrown at client/cmd/root.go:322
}
level := anonymize.ParseLevel(anonymizeLevelFlag)
if !strings.EqualFold(anonymizeLevelFlag, level.String()) {
return false, anonymize.LevelDefault, fmt.Errorf("invalid anonymize level %q: use %q or %q", anonymizeLevelFlag, anonymize.LevelDefault.String(), anonymize.LevelStrict.String())
}
return true, level, nil
}
func getSetupKey() (string, error) {
if setupKeyPath != "" && setupKey == "" {
return getSetupKeyFromFile(setupKeyPath)
}
return setupKey, nil
}
func getSetupKeyFromFile(setupKeyPath string) (string, error) {
data, err := os.ReadFile(setupKeyPath)
if err != nil {
return "", fmt.Errorf("failed to read setup key file: %v", err)
}
return strings.TrimSpace(string(data)), nil
}
func handleRebrand(cmd *cobra.Command) error {
var err error
if slices.Contains(logFiles, defaultLogFile) {
if migrateToNetbird(oldDefaultLogFile, defaultLogFile) {
cmd.Printf("will copy Log dir %s and its content to %s\n", oldDefaultLogFileDir, defaultLogFileDir)
err = cpDir(oldDefaultLogFileDir, defaultLogFileDir)
if err != nil {
return err
}
}
}
if migrateToNetbird(oldDefaultConfigPath, defaultConfigPath) {
cmd.Printf("will copy Config dir %s and its content to %s\n", oldDefaultConfigPathDir, defaultConfigPathDir)
err = cpDir(oldDefaultConfigPathDir, defaultConfigPathDir)View on GitHub (pinned to 93e97f4bf1)