{"record":{"id":"ace7d0cbfd322859","repo":"libnyanpasu/clash-nyanpasu","slug":"failed-to-parse-config-to-yaml-file","errorCode":null,"errorMessage":"failed to parse config to yaml file","messagePattern":"failed to parse config to yaml file","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/tauri/src/ipc.rs","lineNumber":363,"sourceCode":"        Some(state) => {\n            let yaml_value = serde_yaml::to_value(&state.config)?;\n            let json_value = serde_json::to_value(&yaml_value)?;\n            let wrapped: specta_typescript::Any<serde_json::Value> =\n                serde_json::from_value(json_value)?;\n            Ok(Some(wrapped))\n        }\n        None => Ok(None),\n    }\n}\n\n#[tauri::command]\n#[specta::specta]\npub async fn get_runtime_yaml(client: State<'_, NyanpasuClient>) -> Result<String> {\n    let state = client.promoted_runtime().await;\n    let mapping = (state\n        .as_ref()\n        .map(|state| &state.config)\n        .ok_or(anyhow::anyhow!(\"failed to parse config to yaml file\"))\n        .and_then(|config| {\n            serde_yaml::to_string(config).context(\"failed to convert config to yaml\")\n        }))?;\n    Ok(mapping)\n}\n\n#[tauri::command]\n#[specta::specta]\npub async fn inspect_runtime(\n    client: State<'_, NyanpasuClient>,\n) -> Result<Option<crate::client::runtime_inspection::RuntimeInspection>> {\n    Ok(client.inspect_runtime().await)\n}\n\n#[tauri::command]\n#[specta::specta]\npub async fn inspect_runtime_node(\n    client: State<'_, NyanpasuClient>,","sourceCodeStart":345,"sourceCodeEnd":381,"githubUrl":"https://github.com/libnyanpasu/clash-nyanpasu/blob/f7dbce2997c633e484f54788035e770b3ee99773/backend/tauri/src/ipc.rs#L345-L381","documentation":"get_runtime_yaml fetches the promoted runtime config state from NyanpasuClient and serializes it to YAML. If there is no promoted runtime state yet, the ok_or on the None Option produces this error before serialization is attempted. Despite the message, the failure is a missing runtime snapshot, not a YAML parsing problem.","triggerScenarios":"Calling the get_runtime_yaml IPC command before any profile has been activated or after a failed config update left no promoted runtime state.","commonSituations":"Fresh install with no profile selected, first launch before core startup, or a previous runtime-config build failure so promoted_runtime() returns None.","solutions":["Activate/select a profile so the runtime config is generated, then retry.","Trigger a config refresh (reapply the profile or restart the core).","Check logs for an earlier runtime-config build failure and fix that root cause.","Improve the error to distinguish 'no runtime state' from conversion failure."],"exampleFix":"// before\n.ok_or(anyhow::anyhow!(\"failed to parse config to yaml file\"))\n// after\n.ok_or(anyhow::anyhow!(\"no runtime config has been generated yet\"))","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  const yaml = await invoke('get_runtime_yaml');\n} catch (e) {\n  if (String(e).includes('failed to parse config to yaml')) {\n    showEmptyRuntimeState(); // no profile activated yet\n  } else throw e;\n}","preventionTips":["Only query runtime YAML after a profile is activated","Refresh the runtime config after profile changes","Handle first-launch empty state in the UI"],"tags":["yaml","runtime-config","ipc"],"backgroundTag":"missing-config-value","analyzedSha":"f7dbce2997c633e484f54788035e770b3ee99773","analyzedAt":"2026-09-08T01:24:59.197Z","contentChangedAt":"2026-09-08T01:24:59.197Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}