{"record":{"id":"22e5ab501a39aedf","repo":"Kong/insomnia","slug":"expected-single-entity-in-the-data-store-but-f-22e5ab","errorCode":null,"errorMessage":"Expected single ${entity} in the data store, but found multiple (${items.length}).","messagePattern":"Expected single (.+?) in the data store, but found multiple \\((.+?)\\)\\.","errorType":"exception","errorClass":"InsoError","httpStatus":null,"severity":"error","filePath":"packages/insomnia-inso/src/db/models/util.ts","lineNumber":51,"sourceCode":"    return items[0];\n  }\n\n  if (items.length === 0) {\n    return null;\n  }\n\n  throw new InsoError(`Expected single or no ${entity} in the data store, but found multiple (${items.length}).`);\n};\nexport const ensureSingle = <T>(items: T[], entity: string): T => {\n  if (items.length === 1) {\n    return items[0];\n  }\n\n  if (items.length === 0) {\n    throw new InsoError(`Expected single ${entity} in the data store, but found none.`);\n  }\n\n  throw new InsoError(`Expected single ${entity} in the data store, but found multiple (${items.length}).`);\n};\n","sourceCodeStart":33,"sourceCodeEnd":53,"githubUrl":"https://github.com/Kong/insomnia/blob/d9bb2b0142600f21309832daea3317942d285984/packages/insomnia-inso/src/db/models/util.ts#L33-L53","documentation":"Validation helper failure from ensureSingle: a data-store query that must yield exactly one entity of the given type returned multiple duplicates (count is interpolated). Indicates corrupted or duplicated singleton documents in the NeDB data store rather than a user input problem.","triggerScenarios":"Thrown at packages/insomnia-inso/src/db/models/util.ts:51 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Delete or merge the duplicate records in the data store","Restore the project from a clean snapshot","Check for import bugs that duplicated singleton documents"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"d9bb2b0142600f21309832daea3317942d285984","analyzedAt":"2026-08-26T18:04:05.187Z","contentChangedAt":"2026-08-26T18:04:05.187Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}