juspay/hyperswitch · error · Error

Invalid config: missing path

Error message

Invalid config: missing path

What it means

Thrown by setNormalizedValue in cypress-tests Payment/Utils.js when a webhook normalization config object lacks a truthy path property. The function writes a connector transaction id into a webhook body at config.path (dot-separated), so a missing path means it has nowhere to write and aborts.

Source

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

};

// Helper functions
export const shouldExcludeConnector = (connectorId, list) => {
  return Array.isArray(list) && list.includes(connectorId);
};

export const shouldIncludeConnector = (connectorId, list) => {
  if (!Array.isArray(list)) return true;
  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,

View on GitHub (pinned to 9b8b89dc37)

Solutions

  1. Add the required dotted path to the config entry, e.g. { path: 'data.body.id', type: 'string' }
  2. Check for typos: it must be path (not paths / key / field)
  3. Validate normalization configs in one place when the spec loads, so all missing-path entries are listed at once

Example fix

// before
setNormalizedValue(webhookBody, { type: 'string' }, connectorTxnId);

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

Strategy: type-guard

Validate before calling

// Validate all normalization configs when the spec loads
const invalid = normalizationConfigs.filter((c) => !c || typeof c.path !== 'string' || !c.path);
if (invalid.length) {
  throw new Error(`Webhook normalization configs missing 'path': ${JSON.stringify(invalid)}`);
}

Type guard

/** @param {unknown} cfg @returns {cfg is { path: string, type?: 'string' | 'number' }} */
function isNormalizationConfig(cfg) {
  return Boolean(cfg) && typeof cfg === 'object' && typeof cfg.path === 'string' && cfg.path.length > 0;
}

Prevention

When it happens

Trigger: A spec's webhook normalization config passes { type: 'string' } or { } — i.e. an entry where the author omitted path — to setNormalizedValue while mutating an expected webhook body.

Common situations: Hand-editing webhook normalization entries in Payment configs; merging configs where a spread/omit accidentally drops path; new contributors copying a partial example.

Related errors


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