{"record":{"id":"f14d9cf26f197703","repo":"Kong/insomnia","slug":"must-pass-an-xpath-query","errorCode":null,"errorMessage":"Must pass an XPath query.","messagePattern":"Must pass an XPath query\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/insomnia/src/common/templating/local-template-tags.ts","lineNumber":744,"sourceCode":"            }\n\n            if (results.length === 0) {\n              throw new Error(`Returned no results: ${sanitizedFilter}`);\n            }\n\n            if (results.length > 1) {\n              return JSON.stringify(results);\n            }\n\n            if (typeof results[0] !== 'string') {\n              return JSON.stringify(results[0]);\n            }\n            return results[0];\n          }\n          const DOMParser = (await import('@xmldom/xmldom')).DOMParser;\n          const document = new DOMParser().parseFromString(body, 'text/xml');\n          if (sanitizedFilter === undefined) {\n            throw new Error('Must pass an XPath query.');\n          }\n          try {\n            const selectedValues = (await import('xpath')).select(sanitizedFilter, document as unknown as Node); // https://github.com/xmldom/xmldom/issues/724\n\n            let results: { outer: string; inner: string | null }[] = [];\n\n            // Functions return plain strings, numbers, or a boolean—depending on the function.\n            if (\n              typeof selectedValues === 'string' ||\n              typeof selectedValues === 'number' ||\n              typeof selectedValues === 'boolean'\n            ) {\n              const str = String(selectedValues);\n              results = [{ outer: str, inner: str }];\n            } else {\n              results = (selectedValues as Node[])\n                .filter(\n                  sv =>","sourceCodeStart":726,"sourceCodeEnd":762,"githubUrl":"https://github.com/Kong/insomnia/blob/d9bb2b0142600f21309832daea3317942d285984/packages/insomnia/src/common/templating/local-template-tags.ts#L726-L762","documentation":"Error \"Must pass an XPath query.\" thrown in Kong/insomnia.","triggerScenarios":"Thrown at packages/insomnia/src/common/templating/local-template-tags.ts:744 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"}