{"record":{"id":"7c6f0aa10a4d7633","repo":"netbirdio/netbird","slug":"invalid-persistence-value-s-use-on-or-off","errorCode":null,"errorMessage":"invalid persistence value: %s. Use 'on' or 'off'","messagePattern":"invalid persistence value: (.+?)\\. Use 'on' or 'off'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"client/cmd/debug.go","lineNumber":447,"sourceCode":"\t}\n\n\treturn nil\n}\n\nfunc setSyncResponsePersistence(cmd *cobra.Command, args []string) error {\n\tconn, err := getClient(cmd)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer func() {\n\t\tif err := conn.Close(); err != nil {\n\t\t\tlog.Errorf(errCloseConnection, err)\n\t\t}\n\t}()\n\n\tpersistence := strings.ToLower(args[0])\n\tif persistence != \"on\" && persistence != \"off\" {\n\t\treturn fmt.Errorf(\"invalid persistence value: %s. Use 'on' or 'off'\", args[0])\n\t}\n\n\tclient := proto.NewDaemonServiceClient(conn)\n\t_, err = client.SetSyncResponsePersistence(cmd.Context(), &proto.SetSyncResponsePersistenceRequest{\n\t\tEnabled: persistence == \"on\",\n\t})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to set sync response persistence: %v\", status.Convert(err).Message())\n\t}\n\n\tcmd.Printf(\"Sync response persistence set to: %s\\n\", persistence)\n\treturn nil\n}\n\nfunc waitForDurationOrCancel(ctx context.Context, duration time.Duration, cmd *cobra.Command) error {\n\tticker := time.NewTicker(1 * time.Second)\n\tdefer ticker.Stop()\n","sourceCodeStart":429,"sourceCodeEnd":465,"githubUrl":"https://github.com/netbirdio/netbird/blob/93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c/client/cmd/debug.go#L429-L465","documentation":"Pure client-side argument validation in setSyncResponsePersistence (`netbird debug sync-response-persistence <on|off>`). The command lowercases args[0] and accepts only the exact strings 'on' or 'off'; anything else is rejected before the daemon is contacted.","triggerScenarios":"Passing 'true', '1', 'enable', 'yes', or an empty string as the positional argument (e.g. an unset shell variable expanding to empty).","commonSituations":"Scripts assuming boolean flag syntax instead of the positional on/off value; copy-paste from notes using different wording; quoting mistakes that pass an empty argument.","solutions":["Use exactly `netbird debug sync-response-persistence on` or `netbird debug sync-response-persistence off` (case-insensitive: ON, Off also work)","In scripts, default the variable: `netbird debug sync-response-persistence \"${SYNC_PERSIST:-on}\"`"],"exampleFix":"# before\nnetbird debug sync-response-persistence true\n\n# after\nnetbird debug sync-response-persistence on","handlingStrategy":"validation","validationCode":"arg := strings.ToLower(strings.TrimSpace(os.Args[2]))\nif arg != \"on\" && arg != \"off\" {\n\tlog.Fatalf(\"invalid persistence value %q: use 'on' or 'off'\", os.Args[2])\n}\n_ = arg","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Remember the value is positional and literal: on or off, nothing else","In scripts, default unset variables: ${VAR:-off}","The check is case-insensitive but not tolerant of true/false/1/0"],"tags":["cli","argument-validation","netbird-cli","debug"],"backgroundTag":null,"analyzedSha":"93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c","analyzedAt":"2026-08-16T03:09:19.136Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}