BoundaryML/baml · warning

Empty command

Error message

Empty command

What it means

handle_command parses input starting with ':' by splitting the remainder on whitespace; if nothing follows the colon there is no command to dispatch, so it raises 'Empty command'. It is a guard against bare ':' inputs.

Solutions

  1. Type the command name after the colon, e.g. :help or :load
  2. Run :help to see available commands
  3. Remove stray whitespace-only input and re-enter the command

Example fix

// before
:
// after
:help
Defensive patterns

Strategy: validation

Validate before calling

// Caller-side check before dispatching a REPL command
if input.trim() == ":" { return Err(anyhow!("Provide a command after ':'")); }

Try / catch

match result { Err(e) if e.to_string() == "Empty command" => println!("Usage: :help"), other => { let _ = other; } }

Prevention

When it happens

Trigger: Typing just ':' (or ':' followed only by whitespace) at the REPL prompt — parts[1..].split_whitespace() yields no tokens.

Common situations: Accidentally pressing Enter after ':', truncated paste of a command, confusion about command syntax.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12). Data as JSON: /api/errors/1f0e76d2b039230c. Report an issue: GitHub.

Appendix: source

Thrown at engine/baml-runtime/src/cli/repl.rs:1639

            }
        }

        // Cleanup terminal
        disable_raw_mode()?;
        execute!(std::io::stdout(), DisableMouseCapture, LeaveAlternateScreen)?;
        // Ensure the progress bar is hidden on exit
        if supports_progress && progress_active {
            send_graphical_progress(0);
        }
        println!("Goodbye!");
        Ok(())
    }

    #[allow(clippy::print_stdout)]
    fn handle_command(&self, state: &mut ReplState, input: &str) -> Result<Option<String>> {
        let parts: Vec<&str> = input[1..].split_whitespace().collect();
        if parts.is_empty() {
            return Err(anyhow!("Empty command"));
        }

        match parts[0] {
            "load" | "l" => {
                if parts.len() != 2 {
                    return Err(anyhow!("Usage: :load <path> (or :l <path>)"));
                }
                let path = PathBuf::from(parts[1]);
                state.load_baml_sources(path)?;
                Ok(Some("".to_string())) // Success message already printed
            }
            "reset" | "r" => {
                state.reset();
                Ok(Some("".to_string())) // Success message already printed
            }
            "vars" | "v" => Ok(Some(state.list_variables())),
            "thir" => match state.dump_thir() {
                Ok(output) => Ok(Some(output)),

View on GitHub (pinned to bd85ce9dee)