{"record":{"id":"734f0b5907f992ec","repo":"koala73/worldmonitor","slug":"invalid-format-expected-an-object-with-a-data-pro","errorCode":null,"errorMessage":"Invalid format: expected an object with a data property.","messagePattern":"Invalid format: expected an object with a data property\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/utils/settings-persistence.ts","lineNumber":88,"sourceCode":"  URL.revokeObjectURL(url);\n}\n\nexport function importSettings(file: File): Promise<ImportResult> {\n  return new Promise((resolve, reject) => {\n    if (file.size > MAX_IMPORT_SIZE_BYTES) {\n      reject(new Error('File is too large. Maximum size is 5MB.'));\n      return;\n    }\n\n    const reader = new FileReader();\n\n    reader.onload = (e) => {\n      try {\n        const result = e.target?.result as string;\n        const parsed = JSON.parse(result) as ExportedSettings;\n\n        if (!parsed || typeof parsed.data !== 'object' || Array.isArray(parsed.data)) {\n          throw new Error('Invalid format: expected an object with a data property.');\n        }\n\n        if (parsed.version !== 1) {\n          throw new Error(`Unsupported settings version: ${parsed.version}`);\n        }\n\n        let keysImported = 0;\n        const importedKeys: string[] = [];\n        for (const [key, value] of Object.entries(parsed.data)) {\n          if (isSettingsKey(key) && typeof value === 'string') {\n            localStorage.setItem(key, value);\n            keysImported++;\n            importedKeys.push(key);\n          }\n        }\n        invalidatePanelStorageCacheForKeys(importedKeys);\n\n        resolve({ success: true, keysImported });","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/koala73/worldmonitor/blob/a96956387a927b8cd7aa34b0c41fca357e746be9/src/utils/settings-persistence.ts#L70-L106","documentation":"UI error in importSettings: the settings file parsed as JSON but its shape is wrong — there is no usable object 'data' property (missing, non-object, or an array). A shape guard distinguishing valid exports from arbitrary JSON before version migration runs.","triggerScenarios":"Thrown at src/utils/settings-persistence.ts:85 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use a file produced by the app's exportSettings function","Verify the JSON has a top-level 'data' object plus 'version'"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a96956387a927b8cd7aa34b0c41fca357e746be9","analyzedAt":"2026-08-21T16:51:25.751Z","contentChangedAt":"2026-08-21T16:51:25.751Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}