{"record":{"id":"376bcc8b6082a713","repo":"sigoden/aichat","slug":"some-variable-values-are-not-key-value-pairs","errorCode":null,"errorMessage":"Some variable values are not key=value pairs","messagePattern":"Some variable values are not key=value pairs","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/repl/mod.rs","lineNumber":466,"sourceCode":"            }\n            \".rag\" => {\n                Config::use_rag(config, args, abort_signal.clone()).await?;\n            }\n            \".agent\" => match split_first_arg(args) {\n                Some((agent_name, args)) => {\n                    let (new_args, _) = split_args_text(args.unwrap_or_default(), cfg!(windows));\n                    let (session_name, variable_pairs) = match new_args.first() {\n                        Some(name) if name.contains('=') => (None, new_args.as_slice()),\n                        Some(name) => (Some(name.as_str()), &new_args[1..]),\n                        None => (None, &[] as &[String]),\n                    };\n                    let variables: AgentVariables = variable_pairs\n                        .iter()\n                        .filter_map(|v| v.split_once('='))\n                        .map(|(key, value)| (key.to_string(), value.to_string()))\n                        .collect();\n                    if variables.len() != variable_pairs.len() {\n                        bail!(\"Some variable values are not key=value pairs\");\n                    }\n                    if !variables.is_empty() {\n                        config.write().agent_variables = Some(variables);\n                    }\n                    let ret =\n                        Config::use_agent(config, agent_name, session_name, abort_signal.clone())\n                            .await;\n                    config.write().agent_variables = None;\n                    ret?;\n                }\n                None => {\n                    println!(r#\"Usage: .agent <agent-name> [session-name] [key=value]...\"#)\n                }\n            },\n            \".starter\" => match args {\n                Some(id) => {\n                    let mut text = None;\n                    if let Some(agent) = config.read().agent.as_ref() {","sourceCodeStart":448,"sourceCodeEnd":484,"githubUrl":"https://github.com/sigoden/aichat/blob/82976d349ad97ac9aae0655ad631dace5e2a6385/src/repl/mod.rs#L448-L484","documentation":"The `.agent` REPL command accepts variables as `key=value` pairs; pairs without an '=' separator are dropped by `split_once('=')` via `filter_map`. If any pair is dropped (`variables.len() != variable_pairs.len()`), the command bails with this error instead of silently setting incomplete variables.","triggerScenarios":"Running `.agent <name> --var foo` or `.agent <name> --var foo bar` — any variable argument missing the '=' separator between key and value.","commonSituations":"Typing `--var API_KEY` instead of `--var API_KEY=xyz`; shell stripping quotes so a value with spaces splits into separate args (e.g. `--var msg=hello world`); forgetting to quote pairs containing spaces.","solutions":["Ensure every variable argument is formatted as key=value with an '=' separator","Quote variable pairs containing spaces: --var \"msg=hello world\"","Check the agent invocation syntax with .help before retrying"],"exampleFix":"// before: .agent myagent --var API_KEY\n.agent myagent --var API_KEY=sk-123\n// after (quoting for values with spaces)\n.agent myagent --var \"msg=hello world\"","handlingStrategy":"validation","validationCode":"let pairs = [\"API_KEY=sk-123\", \"msg=hello\"];\nassert!(pairs.iter().all(|p| p.split_once('=').is_some()), \"every --var must be key=value\");","typeGuard":"fn parse_var(s: &str) -> Option<(String, String)> {\n    s.split_once('=').map(|(k, v)| (k.to_string(), v.to_string()))\n}","tryCatchPattern":"match run_repl_command(...).await {\n    Err(e) if e.to_string().contains(\"not key=value pairs\") => {\n        eprintln!(\"Format variables as key=value, quoting pairs with spaces\");\n    }\n    other => other?,\n}","preventionTips":["Always include '=' in each --var argument","Quote variable pairs that contain spaces","Test variable syntax with .help examples before long sessions"],"tags":["repl","cli","variables"],"backgroundTag":"invalid-argument-format","analyzedSha":"82976d349ad97ac9aae0655ad631dace5e2a6385","analyzedAt":"2026-09-09T18:33:06.139Z","contentChangedAt":"2026-09-09T18:33:06.139Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}