{"record":{"id":"a4c929131d62190c","repo":"Kong/insomnia","slug":"expected-single-or-no-entity-in-the-data-store","errorCode":null,"errorMessage":"Expected single or no ${entity} in the data store, but found multiple (${items.length}).","messagePattern":"Expected single or no (.+?) 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":40,"sourceCode":"    hint?: string;\n  } = {},\n) => ({\n  name: idIsh,\n  message: indent(config.indent || 0, message),\n  value: `${message} - ${idIsh}`,\n  hint: config.hint || `${idIsh}`,\n});\n\nexport const ensureSingleOrNone = <T>(items: T[], entity: string): T | null | undefined => {\n  if (items.length === 1) {\n    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":22,"sourceCodeEnd":53,"githubUrl":"https://github.com/Kong/insomnia/blob/d9bb2b0142600f21309832daea3317942d285984/packages/insomnia-inso/src/db/models/util.ts#L22-L53","documentation":"Data-integrity guard in ensureSingleOrNone: the query returned more than one instance of an entity that the data model defines as singleton-or-absent (e.g. multiple base environments), indicating duplicated or corrupted data.","triggerScenarios":"Thrown at packages/insomnia-inso/src/db/models/util.ts:40 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the data store and remove the duplicate entities","Re-sync or re-import the project data","Report the corruption if duplicates keep reappearing"],"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"}