{"record":{"id":"cae57aed2ae272c0","repo":"janhq/jan","slug":"invalid-argument-0","errorCode":null,"errorMessage":"Invalid argument: {0}","messagePattern":"Invalid argument: (.+?)","errorType":"validation","errorClass":"ServerError::InvalidArgument","httpStatus":null,"severity":"error","filePath":"src-tauri/plugins/tauri-plugin-llamacpp/src/error.rs","lineNumber":203,"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":185,"sourceCodeEnd":221,"githubUrl":"https://github.com/janhq/jan/blob/fad3f12a147d138388a66f0d92a02b2675f65294/src-tauri/plugins/tauri-plugin-llamacpp/src/error.rs#L185-L221","documentation":"The ServerError::InvalidArgument(String) variant in the tauri-plugin-llamacpp plugin. Its Display is \"Invalid argument: {0}\". On serialization it maps to LlamacppError code INVALID_ARGUMENT with message \"Invalid configuration argument provided.\" and the reason string in details. Unlike the other variants it is constructed explicitly (not via #[from]) when a command validates its inputs and rejects a bad config value.","triggerScenarios":"A server command receives a config value that fails validation (out-of-range number, malformed string, unknown enum) and returns Err(ServerError::InvalidArgument(msg)).","commonSituations":"Context size set to 0 or negative; n_gpu_layers negative; an unknown backend name; a port number out of range; required field missing from the config payload.","solutions":["Validate and clamp config values on the frontend before invoking the command.","Read the serialized `details` to see exactly which argument was rejected.","Reset the offending setting to its default and retry.","Update the plugin if a previously valid value is now rejected due to tightened validation."],"exampleFix":"// Rust\npub fn start_server(cfg: Config) -> ServerResult<()> {\n    if cfg.n_gpu_layers < 0 {\n        return Err(ServerError::InvalidArgument(\"n_gpu_layers must be >= 0\".into()))\n    }\n    Ok(())\n}\n\n// Frontend\ntry { await invoke('start_server', { cfg }) }\ncatch (e) {\n  const err = JSON.parse(e.message)\n  if (err.code === 'INVALID_ARGUMENT') alert(err.details)\n}","handlingStrategy":"validation","validationCode":"function validateConfig(cfg: any) {\n  if (typeof cfg.n_gpu_layers !== 'number' || cfg.n_gpu_layers < 0)\n    throw new Error('n_gpu_layers must be a non-negative number')\n  if (typeof cfg.ctx_size !== 'number' || cfg.ctx_size <= 0)\n    throw new Error('ctx_size must be a positive number')\n}\nvalidateConfig(cfg)\nawait invoke('start_server', { cfg })","typeGuard":null,"tryCatchPattern":"try {\n  await invoke('start_server', { cfg })\n} catch (e) {\n  const err = JSON.parse((e as any).message ?? '{}')\n  if (err.code === 'INVALID_ARGUMENT') showFieldError(err.details)\n  else throw e\n}","preventionTips":["Validate and clamp all config values on the frontend before invoking.","Read `details` to identify the rejected argument.","Reset to defaults when a value is rejected by tightened validation."],"tags":["rust","validation","error-handling","config","tauri"],"backgroundTag":null,"analyzedSha":"fad3f12a147d138388a66f0d92a02b2675f65294","analyzedAt":"2026-08-12T20:33:47.516Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}