Skip to content

Surface invalid JSON errors on the event edit page instead of silently discarding them - #223

Merged
morcen merged 1 commit into
mainfrom
fix/issue-151-events-edit-json-validation
Sep 13, 2026
Merged

morcen merged 1 commit into
mainfrom
fix/issue-151-events-edit-json-validation

Conversation

@morcen

@morcen morcen commented Sep 12, 2026

Copy link
Copy Markdown
Owner

What was broken

On resources/js/Pages/Events/Edit.vue, the Payload/Schema textareas were parsed by a watch() handler that swallowed JSON.parse errors:

watch(payloadText, (val) => {
    try { form.payload = val ? JSON.parse(val) : null } catch {}
})

When the textarea held invalid JSON, the catch block did nothing, so form.payload/form.schema silently 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/schemaText watchers now track a per-field error message (payloadJsonError/schemaJsonError) instead of silently ignoring parse failures.
  • The error is surfaced inline via the existing InputError component next to each textarea.
  • The "Update Event" button is disabled while either field holds invalid JSON, and save() itself also guards against submitting while an error is present (covering Enter-key submits, not just the button).
  • Fixing the JSON clears the error and re-enables saving.

No backend changes were needed — EventController::update already persists whatever payload/schema array it receives; the bug was entirely that the frontend never sent the new value.

Tests

  • Added tests/Feature/DashboardEventUpdateTest.php covering the previously-untested events.update route: a valid update persists the new payload/schema, and cross-user updates are rejected (404).
  • Added a Playwright e2e case to tests/e2e/specs/events.spec.ts that 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.
  • Full PHPUnit suite passes: composer test → 250 passed, 1 skipped (pre-existing).

Fixes #151

…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
morcen merged commit 67ab73c into main Sep 13, 2026
2 checks passed
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
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.

Events/Edit.vue silently discards invalid JSON in Payload/Schema fields — independent instance of #98's bug

1 participant