{"record":{"id":"29dbe6320db07f9e","repo":"jely2002/youtube-dl-gui","slug":"failed-to-retrieve-stronghold-status-strongholdstatus","errorCode":null,"errorMessage":"Failed to retrieve stronghold status: ${strongholdStatus.initError}","messagePattern":"Failed to retrieve stronghold status: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/stores/stronghold.ts","lineNumber":47,"sourceCode":"  headers: string | null;\n}\n\nexport const useStrongholdStore = defineStore('stronghold', () => {\n  const status = ref<StrongholdStatus>(defaultStrongholdStatus);\n  const availableKeys = ref<number[][]>([]);\n\n  async function loadStatus(): Promise<StrongholdStatus> {\n    const strongholdStatus: StrongholdInitPayload = await invoke('stronghold_status');\n    if (strongholdStatus.unlocked && !strongholdStatus.initError) {\n      status.value.unlocked = true;\n\n      availableKeys.value = await invoke('stronghold_keys');\n    } else if (!strongholdStatus.unlocked && !strongholdStatus.initError) {\n      status.value.unlocked = false;\n    } else {\n      status.value.unlocked = false;\n      status.value.initError = strongholdStatus.initError ?? 'Unknown error.';\n      throw new Error(`Failed to retrieve stronghold status: ${strongholdStatus.initError}`);\n    }\n    return status.value;\n  }\n\n  async function initialize(): Promise<StrongholdStatus> {\n    const initStatus: StrongholdInitPayload = await invoke('stronghold_init');\n    if (initStatus.initError) {\n      status.value.initError = initStatus.initError;\n      status.value.unlocked = false;\n      throw new Error(`Failed to initialize stronghold: ${initStatus.initError}`);\n    }\n    status.value.unlocked = initStatus.unlocked;\n\n    availableKeys.value = await invoke('stronghold_keys');\n    return status.value;\n  }\n\n  async function getValues(): Promise<StrongholdFields> {","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/jely2002/youtube-dl-gui/blob/c402ee39c0eabab68934c48f8b787ff37a1577b0/src/stores/stronghold.ts#L29-L65","documentation":"loadStatus queries the Rust backend ('stronghold_status' / 'stronghold_keys') for the stronghold (secure vault) state. When the backend reports an initError, the store records it on status, marks the vault locked, and throws 'Failed to retrieve stronghold status: ${initError}' so callers know status is unreliable.","triggerScenarios":"invoke of the stronghold status command returns a payload with initError set — the stronghold snapshot file is corrupt/unreadable, the password hash mismatch, or the backend failed to initialize the vault at startup.","commonSituations":"Corrupted or manually edited stronghold snapshot; snapshot written by an incompatible app/backend version; missing or wrong file permissions on the vault directory; first run after a failed initialization.","solutions":["Read status.value.initError for the concrete backend message and fix that underlying cause first.","Re-initialize the vault by calling initialize() (stronghold_init) or delete/reset the corrupted snapshot so it is recreated.","Verify the snapshot file location and permissions match what the backend expects.","Wrap loadStatus in try/catch and route the user to a vault setup/recovery screen instead of letting it bubble."],"exampleFix":"// before\nconst status = await strongholdStore.loadStatus();\n// after\nlet status;\ntry {\n  status = await strongholdStore.loadStatus();\n} catch (e) {\n  status = await strongholdStore.initialize(); // or show recovery UI\n}","handlingStrategy":"try-catch","validationCode":"const raw = await invoke<StrongholdStatusPayload>('stronghold_status');\nif (raw.initError) {\n  throw new Error(`Stronghold not ready: ${raw.initError}`);\n}","typeGuard":"const isStrongholdHealthy = (s: StrongholdStatus): boolean => !s.initError;","tryCatchPattern":"try {\n  await strongholdStore.loadStatus();\n} catch (e) {\n  if (e instanceof Error && e.message.startsWith('Failed to retrieve stronghold status')) {\n    router.push({ name: 'vault-recovery' });\n    return;\n  }\n  throw e;\n}","preventionTips":["Read status.initError for the concrete backend cause before retrying.","Handle first-run and corrupted-snapshot cases with a dedicated recovery flow.","Verify snapshot file permissions after app updates or OS upgrades."],"tags":["tauri","stronghold","vault","backend-invocation"],"backgroundTag":"module-init-failed","analyzedSha":"c402ee39c0eabab68934c48f8b787ff37a1577b0","analyzedAt":"2026-09-12T02:01:12.452Z","contentChangedAt":"2026-09-12T02:01:12.452Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}