sigoden/aichat · error

Usage: .set . If value is null, unset key.

Error message

Usage: .set <key> <value>. If value is null, unset key.

What it means

A usage-error guard in the .set config command handler: it fires when update() is called without the expected '<key> <value>' argument structure (missing key or missing value). It is a sentinel validation error describing the correct command syntax, not an underlying I/O or parse failure.

Solutions

  1. Supply both a key and a value, e.g. .set model gpt-4
  2. To remove a key, pass null as the value
  3. Run the config help or .set with no arguments to see available keys
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/config/mod.rs:632 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of sigoden/aichat@82976d349a (2026-09-09). Data as JSON: /api/errors/396ad771fd278f1c. Report an issue: GitHub.

Appendix: source

Thrown at src/config/mod.rs:632

            ("macros_dir", display_path(&Self::macros_dir())),
            ("functions_dir", display_path(&Self::functions_dir())),
            ("messages_file", display_path(&self.messages_file())),
        ];
        if let Ok((_, Some(log_path))) = Self::log_config(self.working_mode.is_serve()) {
            items.push(("log_path", display_path(&log_path)));
        }
        let output = items
            .iter()
            .map(|(name, value)| format!("{name:<24}{value}\n"))
            .collect::<Vec<String>>()
            .join("");
        Ok(output)
    }

    pub fn update(config: &GlobalConfig, data: &str) -> Result<()> {
        let parts: Vec<&str> = data.split_whitespace().collect();
        if parts.len() != 2 {
            bail!("Usage: .set <key> <value>. If value is null, unset key.");
        }
        let key = parts[0];
        let value = parts[1];
        match key {
            "temperature" => {
                let value = parse_value(value)?;
                config.write().set_temperature(value);
            }
            "top_p" => {
                let value = parse_value(value)?;
                config.write().set_top_p(value);
            }
            "use_tools" => {
                let value = parse_value(value)?;
                config.write().set_use_tools(value);
            }
            "max_output_tokens" => {
                let value = parse_value(value)?;

View on GitHub (pinned to 82976d349a)