Surface invalid JSON errors on the event edit page instead of silently discarding them - #223
Merged
Merged
Conversation
…lently discarding them Events/Edit.vue parsed the Payload/Schema textareas in a watcher and swallowed JSON.parse errors, leaving form.payload/form.schema on their last-valid value. Update Event then submitted successfully with the stale data, so a user fixing a broken payload/schema (or making any edit while the JSON happened to be invalid) saw a success redirect while their change was silently dropped. Track parse failures per field, surface them via InputError next to the textarea, and block save() (both the button and Enter-triggered submit) while either field is invalid, so the request is never sent with data the user never intended to submit. Fixes #151
morcen
added a commit
that referenced
this pull request
Sep 14, 2026
…instead of silently discarding them (#224) Events/Index.vue parsed the Payload/Schema textareas in a watcher and swallowed JSON.parse errors, leaving form.payload/form.schema on their last-valid value. Create Event then submitted successfully with the stale data (or null, on first entry), so a user typing a broken payload/schema in the create or duplicate modal saw a success message while their actual input was silently dropped. Track parse failures per field, surface them via InputError next to the textarea, and block saveEvent() (both the button and Enter-triggered submit) while either field is invalid, so the request is never sent with data the user never intended to submit. This mirrors the fix already applied to the event edit page in #223. Fixes #98
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
On
resources/js/Pages/Events/Edit.vue, the Payload/Schema textareas were parsed by awatch()handler that swallowedJSON.parseerrors:When the textarea held invalid JSON, the
catchblock did nothing, soform.payload/form.schemasilently kept their last successfully-parsed value. Clicking "Update Event" then submitted that stale value — the request succeeded (200) and the page redirected back to the events list as if the save worked, but the user's actual edit was never persisted and no error was ever shown.This is a real data-integrity issue: a user trying to fix a broken payload/schema (or making any unrelated edit while the JSON happened to be invalid) would believe their change was saved when it wasn't.
What changed
payloadText/schemaTextwatchers now track a per-field error message (payloadJsonError/schemaJsonError) instead of silently ignoring parse failures.InputErrorcomponent next to each textarea.save()itself also guards against submitting while an error is present (covering Enter-key submits, not just the button).No backend changes were needed —
EventController::updatealready persists whateverpayload/schemaarray it receives; the bug was entirely that the frontend never sent the new value.Tests
tests/Feature/DashboardEventUpdateTest.phpcovering the previously-untestedevents.updateroute: a valid update persists the newpayload/schema, and cross-user updates are rejected (404).tests/e2e/specs/events.spec.tsthat reproduces the original bug end-to-end: breaking the JSON shows the "Invalid JSON" error and disables the Update button, and the page never redirects away with a false success; fixing the JSON clears the error and re-enables the button.composer test→ 250 passed, 1 skipped (pre-existing).Fixes #151