pulumi/pulumi · error

expected <project-number> and <access-token>

Error message

expected <project-number> and <access-token>

What it means

The GCP login provider command requires exactly two positional arguments after the environment reference: a GCP project number and an access token. This error fires when the argument count after resolving the environment ref is anything other than 2.

Source

Thrown at pkg/cmd/esc/cli/env_provider_gcp_login.go:83

			"\n" +
			"See https://www.pulumi.com/docs/esc/integrations/dynamic-login-credentials/gcp-login/\n" +
			"for the full provider reference.\n",
		RunE: func(cmd *cobra.Command, args []string) error {
			ctx := cmd.Context()

			if err := env.esc.getCachedClient(ctx); err != nil {
				return err
			}

			ref, args, err := env.getExistingEnvRef(ctx, args)
			if err != nil {
				return err
			}
			if ref.version != "" {
				return errors.New("the provider command does not accept versions")
			}
			if len(args) != 2 {
				return errors.New("expected <project-number> and <access-token>")
			}
			project, err := strconv.ParseInt(args[0], 10, 64)
			if err != nil {
				return fmt.Errorf("invalid project number %q: must be a positive integer", args[0])
			}
			if project <= 0 {
				return fmt.Errorf("invalid project number %q: must be a positive integer", args[0])
			}
			accessToken := args[1]

			path, err := resource.ParsePropertyPath(pathStr)
			if err != nil {
				return fmt.Errorf("invalid --path: %w", err)
			}

			node := buildGCPLoginStaticNode(project, accessToken, serviceAccount, tokenLifetime)

			var envVars []envVar

View on GitHub (pinned to 793f7b2e16)

Solutions

  1. Pass exactly two positional arguments: <project-number> <access-token>.
  2. Quote the access token if it contains special characters.
  3. Check the command's usage/help output for the exact argument order.
  4. Ensure environment variables used in scripts (e.g. $GCP_TOKEN) are non-empty before invoking.

Example fix

// before (missing token)
esc env configure gcp-login my-org/my-proj/my-env 123456789
// after
esc env configure gcp-login my-org/my-proj/my-env 123456789 "$GCP_ACCESS_TOKEN"
Defensive patterns

Strategy: validation

Validate before calling

if len(args) != 2 {
    return fmt.Errorf("usage: %s <org/project/env> <project-number> <access-token>", cmd.Use)
}

Try / catch

if err := cmd.Run(); err != nil {
    if strings.Contains(err.Error(), "expected <project-number> and <access-token>") {
        return fmt.Errorf("pass exactly two positional args after the env ref")
    }
    return err
}

Prevention

When it happens

Trigger: Calling the subcommand with zero, one, or three-plus positional args, e.g. omitting the access token, passing flags that cobra does not consume, or forgetting one operand entirely.

Common situations: Forgetting the access token in scripts; quoting mistakes that split or join args; copying command lines from docs with placeholders left in; shell word-splitting removing empty-string tokens.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of pulumi/pulumi@793f7b2e16 (2026-08-31). Data as JSON: /api/errors/3a6bfdd840fde818. Report an issue: GitHub.