Fix silent failures when regenerating an endpoint secret - #235
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was broken
regenerateSecret()inresources/js/Pages/Endpoints/Index.vueclosed the edit modal and thenawaited theaxios.post()call to the regenerate-secret endpoint with notry/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
axios.post()call intry/catch.saveEndpoint()/toggleEndpoint()/testEndpoint()), and the modal stays open so the user can retry.Tests
Added
tests/Feature/EndpointRegenerateSecretTest.phpcovering the backend contract the frontend fix relies on:regenerate-secretrequest returnsplain_secretand persists the new secret.Ran the full suite (
php artisan test): 276 passed, 1 pre-existing skip, 0 failures.Fixes #68