netbirdio/netbird · warning

invalid persistence value: %s. Use 'on' or 'off'

Error message

invalid persistence value: %s. Use 'on' or 'off'

What it means

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.

Source

Thrown at client/cmd/debug.go:447

	}

	return nil
}

func setSyncResponsePersistence(cmd *cobra.Command, args []string) error {
	conn, err := getClient(cmd)
	if err != nil {
		return err
	}
	defer func() {
		if err := conn.Close(); err != nil {
			log.Errorf(errCloseConnection, err)
		}
	}()

	persistence := strings.ToLower(args[0])
	if persistence != "on" && persistence != "off" {
		return fmt.Errorf("invalid persistence value: %s. Use 'on' or 'off'", args[0])
	}

	client := proto.NewDaemonServiceClient(conn)
	_, err = client.SetSyncResponsePersistence(cmd.Context(), &proto.SetSyncResponsePersistenceRequest{
		Enabled: persistence == "on",
	})
	if err != nil {
		return fmt.Errorf("failed to set sync response persistence: %v", status.Convert(err).Message())
	}

	cmd.Printf("Sync response persistence set to: %s\n", persistence)
	return nil
}

func waitForDurationOrCancel(ctx context.Context, duration time.Duration, cmd *cobra.Command) error {
	ticker := time.NewTicker(1 * time.Second)
	defer ticker.Stop()

View on GitHub (pinned to 93e97f4bf1)

Solutions

  1. Use exactly `netbird debug sync-response-persistence on` or `netbird debug sync-response-persistence off` (case-insensitive: ON, Off also work)
  2. In scripts, default the variable: `netbird debug sync-response-persistence "${SYNC_PERSIST:-on}"`

Example fix

# before
netbird debug sync-response-persistence true

# after
netbird debug sync-response-persistence on
Defensive patterns

Strategy: validation

Validate before calling

arg := strings.ToLower(strings.TrimSpace(os.Args[2]))
if arg != "on" && arg != "off" {
	log.Fatalf("invalid persistence value %q: use 'on' or 'off'", os.Args[2])
}
_ = arg

Prevention

When it happens

Trigger: Passing 'true', '1', 'enable', 'yes', or an empty string as the positional argument (e.g. an unset shell variable expanding to empty).

Common situations: 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.

Related errors


AI-assisted analysis of netbirdio/netbird@93e97f4bf1 (2026-08-16). Data as JSON: /api/errors/7c6f0aa10a4d7633. Report an issue: GitHub.