pulumi/pulumi · error
parse arguments: %w
Error message
parse arguments: %w
What it means
In the `pulumi do` command's RunFunc setup, command-line flag parsing errors (other than the explicitly allowed unknown flags and --help) are wrapped as 'parse arguments: %w'. The underlying pflag error names the specific bad flag or value.
Source
Thrown at pkg/cmd/pulumi/do/do.go:112
var dryrun bool
var showSecrets bool
var stateless bool
var output string
// buildSubcommand returns the dynamically constructed subcommand along with a cleanup function that must be
// deferred by the caller. The cleanup tears down the provider gRPC channel — running it as a defer inside
// buildSubcommand would close the channel before the subcommand's RunE actually invokes the provider.
buildSubcommand := func(cmd *cobra.Command, args []string) (*cobra.Command, func(), error) {
// We have to do our own flag parsing because we're dynamically building the CLI from provider schemas.
// Parse the arguments so far, but don't error on unknown flags since those will be dynamically added by
// provider plugins.
flags := cmd.Flags()
flags.ParseErrorsAllowlist.UnknownFlags = true
err := flags.Parse(args)
// We shouldn't ever see --help here
contract.Assertf(!errors.Is(err, pflag.ErrHelp), "unexpected --help flag")
if err != nil {
return nil, nil, fmt.Errorf("parse arguments: %w", err)
}
if output != "" && output != "default" && output != "json" {
return nil, nil, fmt.Errorf("unsupported output format %q (supported: default, json)", output)
}
pargs := flags.Args()
// If we don't have any args and no package then this is just `pulumi do` so return nil and the caller handle
// calling help.
if len(pargs) == 0 && pkg == "" {
return nil, nil, nil
}
// If --package was passed use that, else set it based on the token
if pkg == "" {
pkg, _, _ = strings.Cut(pargs[0], ":")
}
View on GitHub (pinned to 793f7b2e16)
Solutions
- Read the wrapped pflag error to identify the offending flag and fix its value or spelling
- Run with --help to list valid flags for the command
- Quote arguments containing spaces or special characters in your script
Example fix
// before pulumi do --timeout notanumber // after pulumi do --timeout 300
Defensive patterns
Strategy: try-catch
Validate before calling
// validate flag values before invoking, e.g.:
if ! timeout.isdigit(): raise SystemExit('--timeout expects an integer') Try / catch
try { run(cmd) } catch (e) { if (e.message.startsWith('parse arguments:')) { console.error('bad flag:', e.cause ?? e.message); process.exit(2) } else throw e } Prevention
- Quote arguments with spaces or special characters in scripts
- Check `--help` for exact flag names and expected value types
- Keep flag builders typed/validated rather than raw string concatenation
When it happens
Trigger: Passing an invalid value to a typed flag (e.g. non-integer to an int flag), or a malformed flag that is not covered by the unknown-flags allowlist, when invoking the internal `pulumi do` entry point.
Common situations: Typo'd flag names not exempted from the allowlist; scripts passing values of the wrong type; quoting errors turning one flag into garbage tokens.
Related errors
- no environment name specified
- unknown output format %q
- the provider command does not accept versions
- expected <project-number> and <access-token>
- invalid project number %q: must be a positive integer
AI-assisted analysis of pulumi/pulumi@793f7b2e16 (2026-08-31).
Data as JSON: /api/errors/3f5b8d96eff74875.
Report an issue: GitHub.