facebook/flow · error

invalid line

Error message

invalid line

What it means

The autocomplete command parses positional arguments; in the two-argument form [line, column] (no filename, input read from stdin), the line argument goes through line.parse().expect("invalid line"). Anything that is not a valid i32 — letters, empty string, floating point, or numbers beyond i32 range — panics with "invalid line" instead of printing a usage error.

Source

Thrown at rust_port/crates/flow_cli/src/autocomplete_command.rs:104

fn file_input_from_stdin(filename: Option<&str>) -> flow_server_utils::file_input::FileInput {
    command_utils::get_file_from_filename_or_stdin(spec().name.as_str(), filename, None)
}

fn parse_args(
    args: Option<Vec<String>>,
) -> (flow_server_utils::file_input::FileInput, Option<(i32, i32)>) {
    match args.as_deref() {
        None | Some([]) => {
            let input = file_input_from_stdin(None);
            extract_cursor(input)
        }
        Some([filename]) => {
            let input = file_input_from_stdin(Some(filename.as_str()));
            extract_cursor(input)
        }
        Some([line, column]) => {
            let cursor = command_utils::convert_input_pos(
                line.parse().expect("invalid line"),
                column.parse().expect("invalid column"),
            );
            let input = file_input_from_stdin(None);
            (input, Some(cursor))
        }
        Some([filename, line, column]) => {
            let cursor = command_utils::convert_input_pos(
                line.parse().expect("invalid line"),
                column.parse().expect("invalid column"),
            );
            let input = file_input_from_stdin(Some(filename.as_str()));
            (input, Some(cursor))
        }
        _ => {
            eprintln!(
                "{}",
                command_spec::command(spec(), |_| {}).string_of_usage()
            );

View on GitHub (pinned to f88ac94bcf)

Solutions

  1. Pass a 1-based integer for line: flow autocomplete 12 5.
  2. Keep the argument order straight — [line column] or [filename line column]; a filename landing in the line slot is the usual shift.
  3. Run the command with no arguments to see the usage string it prints.

Example fix

# before: non-integer first argument in the [line, column] form
flow autocomplete 12x 5    # panics: invalid line

# after: 1-based integers
flow autocomplete 12 5
Defensive patterns

Strategy: validation

Validate before calling

# Validate both position args are integers before invoking autocomplete.
case "$1$2" in ''|*[!0-9-]*) echo "line/column must be integers"; exit 2;; esac

Prevention

When it happens

Trigger: Calling the autocomplete command with exactly two positional args where the first is not an integer, e.g. flow autocomplete 12x 5 or flow autocomplete "" 5 (stdin supplies the file content).

Common situations: Editor integrations passing a cursor marker or flag where the line number belongs; copy-paste invocations missing the filename so arguments shift by one; scripts interpolating empty variables.

Related errors


AI-assisted analysis of facebook/flow@f88ac94bcf (2026-08-20). Data as JSON: /api/errors/4d8a5262a64d197d. Report an issue: GitHub.