hasura/graphql-engine · warning

expected 0 arguments, found: %v

Error message

expected 0 arguments, found: %v

What it means

The `metadata diff` command takes no positional arguments. This error is a usage validation failure: extra arguments were supplied on the command line and the CLI rejects them before doing any work.

Source

Thrown at cli/commands/metadata_handlers.go:423

	}

	if len(o.rawOutput) != 0 {
		// if not a dry run fetch metadata from and server and print it to stdout
		err := getMetadataFromServerAndWriteToStdoutByFormat(o.EC, rawOutputFormat(o.rawOutput))
		if err != nil {
			return errors.E(op, err)
		}

		return nil
	}

	return nil
}

func diff(o *MetadataDiffOptions, diffType DiffType) error {
	var op errors.Op = "commands.diff"
	if len(o.Args) > 0 {
		return errors.E(op, fmt.Errorf("expected 0 arguments, found: %v", o.Args))
	}

	serverMetadata, err := cli.GetCommonMetadataOps(o.EC).ExportMetadata()
	if err != nil {
		return errors.E(op, fmt.Errorf("exporting metadata from server: %w", err))
	}

	var serverMetadataBytes []byte

	serverMetadataBytes, err = io.ReadAll(serverMetadata)
	if err != nil {
		return errors.E(op, fmt.Errorf("reading server metadata: %w", err))
	}

	if diffType == DifftypeYAML {
		serverMetadataBytes, err = metadatautil.JSONToYAML(serverMetadataBytes)
		if err != nil {
			return errors.E(op, fmt.Errorf("parsing server metadata as yaml: %w", err))

View on GitHub (pinned to 724551b9ae)

Solutions

  1. Remove all positional arguments — diff always compares the configured metadata file against the server
  2. To diff a specific file, either update the config's metadata file path or temporarily point --metadata-file (if supported by your CLI version) at the file
  3. Check `metadata diff --help` for the exact accepted flags

Example fix

# before
hasura metadata diff ./metadata.yaml  # expected 0 arguments, found: [./metadata.yaml]
# after
hasura metadata diff  # uses the metadata file from config
Defensive patterns

Strategy: validation

Validate before calling

if len(os.Args) > afterSubcommandIdx {
  return errors.New("metadata diff takes no positional arguments; configure the metadata file path instead")
}

Prevention

When it happens

Trigger: Running `metadata diff something` (any positional argument after the subcommand) — e.g. trying to diff against a specified file via `metadata diff ./mymetadata.yaml`, which the command does not support; the metadata file must come from config.

Common situations: Users assuming diff accepts a file argument (common CLI convention elsewhere); copy-pasted commands from tutorials with an extra token; shell glob expansion appending an unexpected word.

Related errors


AI-assisted analysis of hasura/graphql-engine@724551b9ae (2026-08-28). Data as JSON: /api/errors/17822b2c1dfa39ef. Report an issue: GitHub.