Kong/insomnia · error · Error

Invalid XPath query

Error message

Invalid XPath query: ${sanitizedFilter}

What it means

Template-tag runtime error for {% response 'body' ... %} in XPath mode: evaluating the XPath query against the response body threw (invalid XPath syntax or incompatible node structure). The failing query is interpolated.

Solutions

  1. Fix XPath syntax errors (balanced brackets, valid axes/functions)
  2. Check namespace handling in the query
  3. Validate the expression in an XPath tester before using it in the tag
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at packages/insomnia/src/common/templating/local-template-tags.ts:790 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of Kong/insomnia@d9bb2b0142 (2026-08-26). Data as JSON: /api/errors/999f3a0da4a6621b. Report an issue: GitHub.

Appendix: source

Thrown at packages/insomnia/src/common/templating/local-template-tags.ts:790

                  if (selectedValue.nodeType === Node.ELEMENT_NODE) {
                    return { outer, inner: selectedValue.childNodes.toString() };
                  }
                  if (selectedValue.nodeType === Node.TEXT_NODE) {
                    return { outer, inner: selectedValue.toString().trim() };
                  }
                  return { outer, inner: null };
                });
            }

            if (results.length === 0) {
              throw new Error(`Returned no results: ${sanitizedFilter}`);
            } else if (results.length > 1) {
              throw new Error(`Returned more than one result: ${sanitizedFilter}`);
            }

            return results[0].inner;
          } catch {
            throw new Error(`Invalid XPath query: ${sanitizedFilter}`);
          }
        }
        throw new Error('Oops');
      },
    },
  },
  {
    templateTag: {
      name: 'request',
      displayName: 'Request',
      description: 'reference value from current request',
      args: [
        {
          displayName: 'Attribute',
          type: 'enum',
          options: [
            {
              displayName: 'Name',

View on GitHub (pinned to d9bb2b0142)