juspay/hyperswitch · error · Error

Path does not exist: ${config.path}

Error message

Path does not exist: ${config.path}

What it means

Thrown by setNormalizedValue in Payment/Utils.js when traversing the dot-separated config.path over the webhook body: for every key except the last, the target object must own that property (Object.prototype.hasOwnProperty check). If any intermediate key is missing — e.g. 'data' or 'body' while walking 'data.body.id' — it throws with the full path.

Source

Thrown at cypress-tests/cypress/e2e/configs/Payment/Utils.js:843

  return !list.includes(connectorId);
};

export function setNormalizedValue(
  webhookBody,
  config,
  connectorTransactionID
) {
  if (!config?.path) {
    throw new Error("Invalid config: missing path");
  }
  // Split the dot-separated path into individual keys
  const keys = config.path.split(".");
  let target = webhookBody;

  // Traverse the object until the parent of the final key
  for (const key of keys.slice(0, -1)) {
    if (!Object.prototype.hasOwnProperty.call(target, key)) {
      throw new Error(`Path does not exist: ${config.path}`);
    }
    target = target[key];
  }
  // The final key where the normalized value will be assigned
  const finalKey = keys[keys.length - 1];

  // Coerce value based on expected type
  const normalizedconnectorTransactionID = coerceValue(
    connectorTransactionID,
    config.type
  );

  target[finalKey] = normalizedconnectorTransactionID;
}

function coerceValue(value, type) {
  switch (type) {
    case "string":

View on GitHub (pinned to 9b8b89dc37)

Solutions

  1. Log/inspect the actual webhook body (its JSON structure) and correct config.path to match where the transaction id really lives
  2. Keep per-connector normalization configs — do not reuse one connector's path for another
  3. If the connector payload changed, update both the fixture and the normalization path in the same commit

Example fix

// before
setNormalizedValue(webhookBody, { path: 'data.body.id', type: 'string' }, txnId);
// throws: Path does not exist: data.body.id  (body nests under data.object)

// after
setNormalizedValue(webhookBody, { path: 'data.object.id', type: 'string' }, txnId);
Defensive patterns

Strategy: validation

Validate before calling

// Pre-check a dotted path against the webhook body (mirrors the util's walk)
function pathExists(body, dottedPath) {
  let target = body;
  for (const key of dottedPath.split('.').slice(0, -1)) {
    if (!Object.prototype.hasOwnProperty.call(target, key)) return false;
    target = target[key];
    if (target === null || typeof target !== 'object') return false;
  }
  return true;
}
if (!pathExists(webhookBody, config.path)) {
  throw new Error(`Webhook fixture lacks path ${config.path} — fix fixture or path for connector ${connectorId}`);
}

Prevention

When it happens

Trigger: A normalization config says 'data.body.transaction_id' but the connector's webhook body actually nests the id at 'data.object.id' or similar; or the webhook fixture used for the test does not include the intermediate object, so hasOwnProperty fails mid-walk.

Common situations: Connector webhook payload shape changed (new API version) while test configs kept the old path; path authored for a different connector's webhook format; fixture data pruned during refactoring removing intermediate nodes.

Related errors


AI-assisted analysis of juspay/hyperswitch@9b8b89dc37 (2026-08-16). Data as JSON: /api/errors/9a34c93b186444d2. Report an issue: GitHub.