ellite/Wallos · error · Error

translate("network_response_error")

Error message

translate("network_response_error")

What it means

cloneSubscription POSTs {id} with a CSRF header to a subscriptions endpoint and throws the generic localized network_response_error whenever the response status is not OK. As in renamePayment, the specific HTTP failure is collapsed into one user-facing message, discarding the status code and any server-provided details.

Solutions

  1. Retry the clone while watching the Network tab to capture the real status code and response payload.
  2. Reload the page to refresh the session and window.csrfToken before cloning again.
  3. Confirm the subscription id still exists server-side (it may have been deleted concurrently).
  4. Enhance the throw to include response.status and the parsed error message, mirroring the fetchJson helper pattern used elsewhere in the codebase.

Example fix

// before
if (!response.ok) {
  throw new Error(translate("network_response_error"));
}
return response.json();
// after
if (!response.ok) {
  const body = await response.text();
  let msg = "";
  try { msg = JSON.parse(body).message ?? ""; } catch (e) {}
  throw new Error(`${translate("network_response_error")} (HTTP ${response.status})${msg ? ": " + msg : ""}`);
}
return response.json();
Defensive patterns

Strategy: try-catch

Validate before calling

function canCloneSubscription(id) {
  return Number.isInteger(id) && id > 0 && typeof window.csrfToken === 'string' && window.csrfToken.length > 0;
}

Try / catch

cloneSubscription(id).catch(err => {
  if (err.message.includes('network_response_error')) {
    showErrorMessage(translate('network_response_error') + ' — reload the page and retry');
  } else {
    showErrorMessage(err.message);
  }
});

Prevention

When it happens

Trigger: The clone endpoint returns non-2xx: unknown or already-deleted subscription id causing a 404, CSRF token mismatch returning 419/403, session expiry, or a server 500 while duplicating the subscription record.

Common situations: Clicking 'clone' on a subscription deleted in another tab (404); stale page/session producing CSRF rejection; database constraint failures during the clone causing 500.

Understand the failure class

Background: "API error: {status}" and "HTTP 401/403/404/429/5xx" errors: non-2xx HTTP responses explained — this error's family across 27 libraries.

Related errors


AI-assisted analysis of ellite/Wallos@52820e87ca (2026-09-13). Data as JSON: /api/errors/0b13251b4ee018a2. Report an issue: GitHub.

Appendix: source

Thrown at scripts/subscriptions.js:258

    });
}


function cloneSubscription(event, id) {
  event.stopPropagation();
  event.preventDefault();

  fetch("endpoints/subscription/clone.php", {
    method: "POST",
    headers: {
      "Content-Type": "application/json",
      "X-CSRF-Token": window.csrfToken,
    },
    body: JSON.stringify({ id: id }),
  })
    .then((response) => {
      if (!response.ok) {
        throw new Error(translate("network_response_error"));
      }
      return response.json();
    })
    .then((data) => {
      if (data.success) {
        const newId = data.id;
        fetchSubscriptions(newId, event, "clone");
        showSuccessMessage(decodeURI(data.message));
      } else {
        showErrorMessage(data.message || translate("error"));
      }
    })
    .catch((error) => {
      showErrorMessage(error.message || translate("error"));
    });
}


View on GitHub (pinned to 52820e87ca)