{"record":{"id":"fce3ef0d8631d89d","repo":"cloudflare/cloudflared","slug":"errnotunnelid","errorCode":"ErrNoTunnelID","errorMessage":"no tunnel ID provided","messagePattern":"no tunnel ID provided","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/cloudflared/cliutil/management.go","lineNumber":22,"sourceCode":"\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"time\"\n\n\t\"github.com/google/uuid\"\n\t\"github.com/mattn/go-colorable\"\n\t\"github.com/rs/zerolog\"\n\t\"github.com/urfave/cli/v2\"\n\n\t\"github.com/cloudflare/cloudflared/cfapi\"\n\tcfdflags \"github.com/cloudflare/cloudflared/cmd/cloudflared/flags\"\n\t\"github.com/cloudflare/cloudflared/credentials\"\n)\n\n// Error definitions for management token operations\nvar (\n\tErrNoTunnelID      = errors.New(\"no tunnel ID provided\")\n\tErrInvalidTunnelID = errors.New(\"unable to parse provided tunnel id as a valid UUID\")\n)\n\n// GetManagementToken acquires a management token from Cloudflare API for the specified resource\nfunc GetManagementToken(c *cli.Context, log *zerolog.Logger, res cfapi.ManagementResource, buildInfo *BuildInfo) (string, error) {\n\tuserCreds, err := credentials.Read(c.String(cfdflags.OriginCert), log)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tvar apiURL string\n\tif userCreds.IsFEDEndpoint() {\n\t\tapiURL = credentials.FedRampBaseApiURL\n\t} else {\n\t\tapiURL = c.String(cfdflags.ApiURL)\n\t}\n\n\tclient, err := userCreds.Client(apiURL, buildInfo.UserAgent(), log)","sourceCodeStart":4,"sourceCodeEnd":40,"githubUrl":"https://github.com/cloudflare/cloudflared/blob/2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f/cmd/cloudflared/cliutil/management.go#L4-L40","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Append the tunnel UUID: `cloudflared tunnel info <tunnel-uuid>`.","List tunnel IDs with `cloudflared tunnel list` if you do not know the UUID.","Fix scripts so the tunnel ID variable is populated (e.g. fetch it or fail early if empty)."],"exampleFix":"# before\nTUNNEL_ID=\"\"\ncloudflared tunnel info $TUNNEL_ID\n# after\nTUNNEL_ID=$(cloudflared tunnel list --output json | jq -r '.[0].id')\ncloudflared tunnel info \"$TUNNEL_ID\"","handlingStrategy":"validation","validationCode":"if [ -z \"$1\" ]; then\n  echo \"usage: cloudflared tunnel info <tunnel-uuid>\"; exit 2\nfi","typeGuard":null,"tryCatchPattern":"token, err := cliutil.GetManagementToken(c, log, res, buildInfo)\nif err != nil {\n    if errors.Is(err, cliutil.ErrNoTunnelID) {\n        return cli.ShowSubcommandHelp(c) // print usage instead of raw error\n    }\n    return err\n}","preventionTips":["Store the tunnel UUID in config/deploy tooling, not the human-readable name.","Run `cloudflared tunnel list` to retrieve IDs when unsure.","Validate positional arg count in wrapper scripts before invoking cloudflared."],"tags":["cli","management","tunnel"],"backgroundTag":"missing-cli-argument","analyzedSha":"2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f","analyzedAt":"2026-09-06T04:14:33.757Z","contentChangedAt":"2026-09-06T04:14:33.757Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}