cloudflare/cloudflared · error

ErrNoTunnelID

ErrNoTunnelID

Error message

no tunnel ID provided

What it means

GetManagementToken (used by cloudflared management commands such as `cloudflared tunnel info`) requires the tunnel UUID as the first positional argument. ErrNoTunnelID is a sentinel error thrown when that argument is missing, before any API call is made.

Source

Thrown at cmd/cloudflared/cliutil/management.go:22

	"errors"
	"fmt"
	"io"
	"os"
	"time"

	"github.com/google/uuid"
	"github.com/mattn/go-colorable"
	"github.com/rs/zerolog"
	"github.com/urfave/cli/v2"

	"github.com/cloudflare/cloudflared/cfapi"
	cfdflags "github.com/cloudflare/cloudflared/cmd/cloudflared/flags"
	"github.com/cloudflare/cloudflared/credentials"
)

// Error definitions for management token operations
var (
	ErrNoTunnelID      = errors.New("no tunnel ID provided")
	ErrInvalidTunnelID = errors.New("unable to parse provided tunnel id as a valid UUID")
)

// GetManagementToken acquires a management token from Cloudflare API for the specified resource
func GetManagementToken(c *cli.Context, log *zerolog.Logger, res cfapi.ManagementResource, buildInfo *BuildInfo) (string, error) {
	userCreds, err := credentials.Read(c.String(cfdflags.OriginCert), log)
	if err != nil {
		return "", err
	}

	var apiURL string
	if userCreds.IsFEDEndpoint() {
		apiURL = credentials.FedRampBaseApiURL
	} else {
		apiURL = c.String(cfdflags.ApiURL)
	}

	client, err := userCreds.Client(apiURL, buildInfo.UserAgent(), log)

View on GitHub (pinned to 2253eeeb25)

Solutions

  1. Append the tunnel UUID: `cloudflared tunnel info <tunnel-uuid>`.
  2. List tunnel IDs with `cloudflared tunnel list` if you do not know the UUID.
  3. Fix scripts so the tunnel ID variable is populated (e.g. fetch it or fail early if empty).

Example fix

# before
TUNNEL_ID=""
cloudflared tunnel info $TUNNEL_ID
# after
TUNNEL_ID=$(cloudflared tunnel list --output json | jq -r '.[0].id')
cloudflared tunnel info "$TUNNEL_ID"
Defensive patterns

Strategy: validation

Validate before calling

if [ -z "$1" ]; then
  echo "usage: cloudflared tunnel info <tunnel-uuid>"; exit 2
fi

Try / catch

token, err := cliutil.GetManagementToken(c, log, res, buildInfo)
if err != nil {
    if errors.Is(err, cliutil.ErrNoTunnelID) {
        return cli.ShowSubcommandHelp(c) // print usage instead of raw error
    }
    return err
}

Prevention

When it happens

Trigger: Running a management subcommand (e.g. `cloudflared tunnel info` without a tunnel ID) where c.Args().First() returns an empty string because no positional tunnel ID was supplied.

Common situations: Forgetting the positional arg after flags (`cloudflared tunnel info --output json` with no ID); scripts where a variable holding the tunnel ID is empty; confusion between flags and positional arguments.

Understand the failure class

Background: "no subcommand specified" and "... is required": CLI errors when a required argument is missing — this error's family across 13 libraries.

Related errors


AI-assisted analysis of cloudflare/cloudflared@2253eeeb25 (2026-09-06). Data as JSON: /api/errors/fce3ef0d8631d89d. Report an issue: GitHub.