tailscale/tailscale · error

expected at least one argument after method

Error message

expected at least one argument after method

What it means

After runLocalAPI (debug.go:550) consumes an optional leading HTTP method token (GET/POST/PUT/DELETE/PATCH recognized by looksLikeHTTPMethod), it requires at least one more argument for the path. This error means the method was the only argument supplied.

Source

Thrown at cmd/tailscale/cli/debug.go:550

		}
	}
	return true
}

var localAPIFlags struct {
	verbose bool
}

func runLocalAPI(ctx context.Context, args []string) error {
	if len(args) == 0 {
		return errors.New("expected at least one argument")
	}
	method := "GET"
	if looksLikeHTTPMethod(args[0]) {
		method = args[0]
		args = args[1:]
		if len(args) == 0 {
			return errors.New("expected at least one argument after method")
		}
	}
	path := args[0]
	if !strings.HasPrefix(path, "/localapi/") {
		if !strings.Contains(path, "/") {
			path = "/localapi/v0/" + path
		} else {
			path = "/localapi/" + path
		}
	}

	var body io.Reader
	if len(args) > 1 {
		if args[1] == "-" {
			fmt.Fprintf(Stderr, "# reading request body from stdin...\n")
			all, err := io.ReadAll(os.Stdin)
			if err != nil {
				return fmt.Errorf("reading Stdin: %q", err)

View on GitHub (pinned to cfe32b8be6)

Solutions

  1. Append a path after the method: tailscale debug local-api POST /localapi/v0/dev-set-state
  2. Check the variable holding the path is non-empty before invoking

Example fix

# before
tailscale debug local-api POST
# after
tailscale debug local-api POST /localapi/v0/dev-set-state
Defensive patterns

Strategy: validation

Validate before calling

# shell: when a method is given, a path must follow
if printf '%s' "$1" | grep -qxE 'GET|POST|PUT|DELETE|PATCH'; then
  : "${2:?need a path after the HTTP method}"
fi
tailscale debug local-api "$@"

Prevention

When it happens

Trigger: 'tailscale debug local-api POST' with no endpoint; a script that interpolates "$METHOD $PATH" where PATH is empty.

Common situations: Dynamic construction of the request line where the path variable is empty or was consumed by earlier argument parsing.

Related errors


AI-assisted analysis of tailscale/tailscale@cfe32b8be6 (2026-08-15). Data as JSON: /api/errors/008c83307ed126b2. Report an issue: GitHub.