{"record":{"id":"27e85432f2665139","repo":"jlcodes99/cockpit-tools","slug":"invalid-format","errorCode":null,"errorMessage":"Invalid format","messagePattern":"Invalid format","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/components/MfaVaultManager.tsx","lineNumber":392,"sourceCode":"              resolve();\n              return;\n            }\n            const reader = new FileReader();\n            reader.onload = (res) => {\n              dataStr = res.target?.result as string;\n              resolve();\n            };\n            reader.onerror = reject;\n            reader.readAsText(file);\n          };\n          input.click();\n        });\n      }\n\n      if (!dataStr) return;\n\n      const parsed = JSON.parse(dataStr);\n      if (!Array.isArray(parsed)) throw new Error('Invalid format');\n\n      setRecords(prev => {\n        const incoming = parsed\n          .map(normalizeMfaRecord)\n          .filter((item): item is MfaRecord => !!item);\n        return dedupeMfaRecordsBySecret([...incoming, ...prev]);\n      });\n    } catch (err) {\n      console.error('Import error:', err);\n      alert(t('mfaVault.importErrorMsg', '导入失败，请检查文件内容格式。'));\n    }\n  };\n\n  const handlePasteImage = async (event: ClipboardEvent<HTMLInputElement>) => {\n    const items = Array.from(event.clipboardData?.items || []);\n    const imageItem = items.find(item => item.type.startsWith('image/'));\n    if (!imageItem) return;\n","sourceCodeStart":374,"sourceCodeEnd":410,"githubUrl":"https://github.com/jlcodes99/cockpit-tools/blob/1ed8b77992d62ca81fabf744deb0839ad361d5bf/src/components/MfaVaultManager.tsx#L374-L410","documentation":"Guard in MfaVaultManager's import handler: the chosen file was read and JSON.parse succeeded, but the parsed root is not an array. The MFA vault import expects a JSON array of record objects, so any other shape (single object, wrapper with metadata) is rejected as 'Invalid format' before merging into the vault.","triggerScenarios":"Thrown at src/components/MfaVaultManager.tsx:392 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Re-export the MFA records and ensure the export root is a JSON array","If importing a single record, wrap it in an array","Check that the file was not produced by a different tool with a wrapper schema"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"1ed8b77992d62ca81fabf744deb0839ad361d5bf","analyzedAt":"2026-09-05T09:51:41.178Z","contentChangedAt":"2026-09-05T09:51:41.178Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}