Skip to content

Fix silent failures when regenerating an endpoint secret - #235

Merged
morcen merged 1 commit into
mainfrom
fix/issue-68-regenerate-secret-error-handling
Sep 25, 2026
Merged

morcen merged 1 commit into
mainfrom
fix/issue-68-regenerate-secret-error-handling

Conversation

@morcen

@morcen morcen commented Sep 24, 2026 •

Copy link
Copy Markdown
Owner

What was broken

regenerateSecret() in resources/js/Pages/Endpoints/Index.vue closed the edit modal and then awaited the axios.post() call to the regenerate-secret endpoint with no try/catch. Any request failure (expired session/CSRF token, network error, server error, or hitting the secret-rotation rate limit) produced an unhandled promise rejection, leaving the user staring at a closed modal with no new secret revealed and no error message — the only trace was an unhandled rejection in the browser console.

Since this is the flow used to rotate an endpoint's HMAC webhook-signing secret, a silent failure here is especially bad: a user can't tell whether the secret was actually rotated server-side or not.

What changed

  • Wrapped the axios.post() call in try/catch.
  • The edit modal now only closes and reveals the new one-time secret on success.
  • On failure, an error alert is shown (consistent with the existing error-handling convention already used elsewhere in this file, e.g. saveEndpoint()/toggleEndpoint()/testEndpoint()), and the modal stays open so the user can retry.

Tests

Added tests/Feature/EndpointRegenerateSecretTest.php covering the backend contract the frontend fix relies on:

  • A successful regenerate-secret request returns plain_secret and persists the new secret.
  • A failed (rate-limited, 429) request does not carry a secret.

Ran the full suite (php artisan test): 276 passed, 1 pre-existing skip, 0 failures.

Fixes #68

regenerateSecret() closed the edit modal and awaited the API call with
no try/catch, so any failure (expired session, network error, rate
limiting) left the user staring at a closed modal with no secret
revealed and no error message. Keep the modal open until the request
succeeds, and show an error alert on failure, consistent with the
error handling already used elsewhere in this file.
@morcen
morcen merged commit 0eddc33 into main Sep 25, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

regenerateSecret() has no error handling — a failed request leaves the modal closed with no secret or error shown

1 participant