{"record":{"id":"cae57aed2ae272c0","repo":"janhq/jan","slug":"invalid-argument-0","errorCode":null,"errorMessage":"Invalid argument: {0}","messagePattern":"Invalid argument: (.+?)","errorType":"validation","errorClass":"ServerError","httpStatus":null,"severity":"error","filePath":"src-tauri/plugins/tauri-plugin-llamacpp/src/error.rs","lineNumber":205,"sourceCode":"    let candidate = candidate.trim_matches(['\\'', '\"', '(', ')', ',', '.'].as_ref());\n    if looks_like_library(candidate) && !found.iter().any(|f| f == candidate) {\n        found.push(candidate.to_string());\n    }\n}\n\n// Error type for server commands\n#[derive(Debug, thiserror::Error)]\npub enum ServerError {\n    #[error(transparent)]\n    Llamacpp(#[from] LlamacppError),\n\n    #[error(\"IO error: {0}\")]\n    Io(#[from] std::io::Error),\n\n    #[error(\"Tauri error: {0}\")]\n    Tauri(#[from] tauri::Error),\n\n    #[error(\"Invalid argument: {0}\")]\n    InvalidArgument(String),\n}\n\n// impl serialization for tauri\nimpl serde::Serialize for ServerError {\n    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>\n    where\n        S: serde::Serializer,\n    {\n        let error_to_serialize: LlamacppError = match self {\n            ServerError::Llamacpp(err) => err.clone(),\n            ServerError::Io(e) => LlamacppError::new(\n                ErrorCode::IoError,\n                \"An input/output error occurred.\".into(),\n                Some(e.to_string()),\n            ),\n            ServerError::Tauri(e) => LlamacppError::new(\n                ErrorCode::InternalError,","sourceCodeStart":187,"sourceCodeEnd":223,"githubUrl":"https://github.com/janhq/jan/blob/7205d770c1e097c3daf35a911176410e93bc5564/src-tauri/plugins/tauri-plugin-llamacpp/src/error.rs#L187-L223","documentation":"ServerError::InvalidArgument is thrown when a command receives a parameter that fails validation, displayed as \"Invalid argument: {0}\" with a descriptive message. Unlike the #[from] variants it must be constructed explicitly, so it marks caller-supplied input problems rather than environmental failures. It is the plugin's contract-violation signal for IPC calls.","triggerScenarios":"A #[tauri::command] validates its inputs (empty model name, malformed path, out-of-range port, negative context size) and returns ServerError::InvalidArgument(String) with the reason.","commonSituations":"Frontend sends an empty or null-ish model path, a bad temperature/seed value, or a path with unexpected characters; API changes leave the UI sending stale parameter shapes.","solutions":["Read the embedded message; it names the offending parameter and the violated rule.","Validate inputs on the frontend before invoking the command.","Fix the calling code to send values matching the command's expected types and ranges.","Check for recent signature changes between frontend invoke calls and Rust command definitions."],"exampleFix":"// before: sending unvalidated input from the UI\ninvoke('start_server', { modelPath: userInput });\n// after\nif (!userInput || !userInput.endsWith('.gguf')) throw new Error('modelPath required');\ninvoke('start_server', { modelPath: userInput });","handlingStrategy":"validation","validationCode":"function validateStartArgs(args) {\n  if (!args.modelPath || typeof args.modelPath !== 'string' || !args.modelPath.endsWith('.gguf'))\n    throw new Error('modelPath must be a .gguf file path');\n  if (args.contextSize != null && (!Number.isInteger(args.contextSize) || args.contextSize <= 0))\n    throw new Error('contextSize must be a positive integer');\n}","typeGuard":"function isValidStartArgs(a) {\n  return typeof a === 'object' && a !== null\n    && typeof a.modelPath === 'string' && a.modelPath.length > 0;\n}","tryCatchPattern":"try {\n  await invoke('start_server', { modelPath });\n} catch (msg) {\n  if (String(msg).startsWith('Invalid argument:')) {\n    showInputError(String(msg).slice('Invalid argument:'.length));\n  } else { throw msg; }\n}","preventionTips":["Validate all inputs in the UI layer before invoke().","Mirror Rust command signatures exactly in frontend invoke payloads.","Keep a shared schema for command parameters to catch drift early.","Never send empty strings or null where the command expects a value."],"tags":["rust","tauri","validation","input"],"backgroundTag":"invalid-argument-value","analyzedSha":"7205d770c1e097c3daf35a911176410e93bc5564","analyzedAt":"2026-09-17T14:27:30.100Z","contentChangedAt":"2026-09-17T14:27:30.100Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}