hasura/graphql-engine · error

error getting user input: %w

Error message

error getting user input: %w

What it means

During `hasura migrate delete` with --all and without --force in a terminal, the CLI asks for a yes/no confirmation via util.GetYesNoPrompt. This wraps failures reading that user input (stdin closed, invalid input loop, terminal error).

Source

Thrown at cli/commands/migrate_delete.go:64

					stderrors.New("at least one flag [--all , --version] should be set"),
				)
			}

			if cmd.Flags().Changed("all") && cmd.Flags().Changed("version") {
				return errors.E(op, stderrors.New("only one of [--all , --version] should be set"))
			}

			return nil
		},
		RunE: func(cmd *cobra.Command, args []string) error {
			op := genOpName(cmd, "RunE")
			// exit if user inputs n for clearing migrations
			if cmd.Flags().Changed("all") && !opts.Force && opts.EC.IsTerminal {
				confirmation, err := util.GetYesNoPrompt(
					"clear all migrations of database and it's history on the server?",
				)
				if err != nil {
					return errors.E(op, fmt.Errorf("error getting user input: %w", err))
				}

				if !confirmation {
					return nil
				}
			}

			if ec.AllDatabases && !opts.Force {
				confirmation, err := util.GetYesNoPrompt(
					"clear all mentioned migrations of all databases and it's history on the server?",
				)
				if err != nil {
					return errors.E(op, fmt.Errorf("error getting user input: %w", err))
				}

				if !confirmation {
					return nil
				}

View on GitHub (pinned to 724551b9ae)

Solutions

  1. Use --force in non-interactive scripts: hasura migrate delete --all --force
  2. Pipe an explicit answer: echo y | hasura migrate delete --all (where supported)
  3. Avoid closing stdin when running interactively

Example fix

# before
hasura migrate delete --all   # stdin is /dev/null in CI
# after
hasura migrate delete --all --force
Defensive patterns

Strategy: validation

Validate before calling

if [ ! -t 0 ] && [ "$FORCE" != "1" ]; then FORCE_FLAG=--force; else FORCE_FLAG=; fi

Try / catch

if strings.Contains(err.Error(), "error getting user input") { /* rerun with --force */ }

Prevention

When it happens

Trigger: Running migrate delete --all in an environment where stdin is closed or non-interactive (piped CI job) but the CLI still detected a terminal, or EOF on the prompt.

Common situations: CI jobs forgetting --force; piping input that ends before answering; running under a broken TTY wrapper.

Related errors


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