{"record":{"id":"c2f8d992a390135a","repo":"Kong/insomnia","slug":"could-not-get-folder-by-index-folderindex-must","errorCode":null,"errorMessage":"Could not get folder by index ${folderIndex}. Must be between 0-${ancestors.length - 1}","messagePattern":"Could not get folder by index (.+?)\\. Must be between 0-(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/insomnia/src/common/templating/local-template-tags.ts","lineNumber":995,"sourceCode":"          }\n          if (attribute === 'oauth2') {\n            return access.accessToken;\n          }\n          if (attribute === 'oauth2-identity') {\n            return access.identityToken;\n          }\n          if (attribute === 'oauth2-refresh') {\n            return access.refreshToken;\n          }\n        }\n        if (attribute === 'name') {\n          return request.name;\n        }\n        if (attribute === 'folder') {\n          const ancestors = await context.util.models.request.getAncestors(request);\n          const doc = ancestors[folderIndex || 0];\n          if (!doc) {\n            throw new Error(`Could not get folder by index ${folderIndex}. Must be between 0-${ancestors.length - 1}`);\n          }\n          return doc ? doc.name : null;\n        }\n\n        return null;\n      },\n    },\n  },\n];\n\nexport const localTemplateTags: TemplateTag[] = localTemplatePlugins.map(t => ({\n  plugin: {\n    name: t.templateTag.name,\n    description: 'Built-in plugin',\n    version: '0.0.0',\n    directory: '',\n    config: {\n      disabled: false,","sourceCodeStart":977,"sourceCodeEnd":1013,"githubUrl":"https://github.com/Kong/insomnia/blob/d9bb2b0142600f21309832daea3317942d285984/packages/insomnia/src/common/templating/local-template-tags.ts#L977-L1013","documentation":"Error \"Could not get folder by index ${folderIndex}. Must be between 0-${ancestors.length - 1}\" thrown in Kong/insomnia.","triggerScenarios":"Thrown at packages/insomnia/src/common/templating/local-template-tags.ts:995 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"d9bb2b0142600f21309832daea3317942d285984","analyzedAt":"2026-08-26T18:04:05.187Z","schemaVersion":2},"datasetVersion":"2026-08-26T21:11:00.512Z"}