Skip to content

GH#79: fix AJAX validation-error response handling - #82

Merged
superdav42 merged 2 commits into
mainfrom
feature/auto-20261015-022352-gh79
Oct 15, 2026
Merged

superdav42 merged 2 commits into
mainfrom
feature/auto-20261015-022352-gh79

Conversation

@superdav42

@superdav42 superdav42 commented Oct 15, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Fixes the HTTP-success validation-error path by removing the unused commentUrl argument from its debug log. That argument was evaluated before the later const commentUrl initialization, preventing the existing error handler from running in the source script, even with debugging disabled.

The extracted-error handling, submitting-guard cleanup, successful-comment path, and server validation policy are unchanged.

Resolves #79

Files Changed

  • src/js/frontend/wp-ajaxify-comments.js: remove the premature debug argument.
  • dist/wpac-frontend-js.js and dist/wpac-frontend-js.asset.php: regenerate the combined frontend bundle and version.
  • dist/wpac-frontend-wp-ajaxify-comments.js and dist/wpac-frontend-wp-ajaxify-comments.asset.php: regenerate the standalone frontend bundle and version.

Generated assets come from the existing production webpack build. Unrelated generated output is excluded. No dependencies, server-side validation, repository test infrastructure, fixtures, or CI gates were changed.

Runtime Testing

  • Risk level: High — comment form handler.
  • Verification: runtime-verified for the changed frontend path.
  • Final pushed head: 6e1c9a0ad29bd2c3122bffb1ed5aacd24c7789cd.
  • Runtime-tested revision: a2f2645d1ddc366c8be9063585d78c105b56aa4f. All five delivered source/asset files are byte-identical at the final head, verified with git diff --exit-code over those exact paths. Only history finalization and exclusion of automatically generated runtime bookkeeping followed the browser run. Existing lint and syntax checks were repeated on the final head.
  • Environment: Node 22.22.2, webpack 5.111.1, ESLint 8.57.1, jQuery 3.7.1, Chromium 152, and an existing WordPress 6.8.2 / PHP 8.2 local test site.

Acceptance matrix

Criterion Result Evidence
HTTP 2xx plus X-WPAC-ERROR: 1, debug off and on Satisfied Six browser cases across the source and both rebuilt bundles displayed the actual WordPress error, Error: Please type your comment text., replacing the loading message.
No ReferenceError; loading completes; submitting guard clears Satisfied All ten browser flows reached AJAX completion with WPAC_SUBMITTING false and no JavaScript exceptions.
Corrected comment can subsequently be submitted; ordinary success remains functional Satisfied After a validation error, a corrected real WordPress POST succeeded, emitted wpacAfterPostComment, displayed the awaiting-moderation success message, and retained one usable comment form.
Non-2xx validation failures remain handled Satisfied Three HTTP 400 browser cases, one per source/bundle, displayed the same extracted WordPress error and cleared the submitting guard.
Existing lint and build pass Satisfied Commands below passed; only the five authorized files are included.

Coverage limit: The existing local WordPress site did not have a deployed Ajaxify server plugin. The current source/bundles were loaded into its real comment page using the existing browser tooling. One-shot DevTools response overrides supplied the X-WPAC-ERROR header, HTTP 400 status for non-2xx cases, and successful-comment metadata normally supplied by the plugin. WordPress validation/page response bodies and the corrected POST were real. This is frontend-path runtime evidence, not an unmodified end-to-end deployment of the server plugin or a reproduction of the historical support-site redirect.

Existing checks

  • npm ci --no-audit --no-fund
  • npm run lint:js -- --max-warnings=0
  • npm run build
  • node --check src/js/frontend/wp-ajaxify-comments.js
  • node --check dist/wpac-frontend-js.js
  • node --check dist/wpac-frontend-wp-ajaxify-comments.js
  • php -l dist/wpac-frontend-js.asset.php
  • php -l dist/wpac-frontend-wp-ajaxify-comments.asset.php
  • git diff --check origin/main...HEAD
  • The existing pre-push hook passed frontend lint on the implementation pushes. Automatically regenerated, untracked runtime bookkeeping caused the hook to skip its final repetition; the explicit frontend lint and source/bundle/manifest syntax checks above were run successfully on the final pushed head instead. That bookkeeping is not in the final PR diff.

The production build exits successfully with existing Sass deprecation warnings in untouched SCSS and a babel-plugin-lodash deprecation notice. These are outside this source-only validation fix; their files and dependency declarations are unchanged.

Review

  • Direct diff/scope review: only the premature source argument and the four relevant generated artifacts changed.
  • Independent, inference-only source closeout review: no introduced P0/P1 defect found. The reviewer received the source deletion and adjacent callback contracts, not the generated bundles or full-site runtime.
  • Reviewed branch evidence digest: 22610bc48894e83c03354f58573fab078a07cba40d22f5d3d4ce15b054021298.
  • Final-head branch evidence digest: c9475f33b3f131f20bdfa78659a3d99c96a5b3ed7b9b8ef60ccc032af453a1d4. The source/asset file contents reviewed and runtime-tested above are unchanged.

Rollback

Revert the scoped source and generated-asset changes together.


aidevops.sh v3.39.27 plugin for OpenCode v1.19.0 with gpt-6.1-sol spent 22m and 175,182 tokens on this as a headless worker.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed an issue that could interrupt handling of errors returned when submitting comments asynchronously. Comment error responses are now handled without referencing the comment URL before it is available, helping prevent unexpected problems during the submission process.

@superdav42 superdav42 added the origin:worker Created by headless/pulse worker session label Oct 15, 2026
@coderabbitai

coderabbitai Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: Ultimate-Multisite/wp-ajaxify-comments/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b4a40ddf-07ec-4813-969d-2fb017b53522
📥 Commits

Reviewing files that changed from the base of the PR and between 1bb0b9c and 6e1c9a0.

⛔ Files ignored due to path filters: 4
  • dist/wpac-frontend-js.asset.php is excluded by !**/dist/**
  • dist/wpac-frontend-js.js is excluded by !**/dist/**
  • dist/wpac-frontend-wp-ajaxify-comments.asset.php is excluded by !**/dist/**
  • dist/wpac-frontend-wp-ajaxify-comments.js is excluded by !**/dist/**
📒 Files selected for processing: 1
  • src/js/frontend/wp-ajaxify-comments.js
💤 Files with no reviewable changes: 1
  • src/js/frontend/wp-ajaxify-comments.js

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

📝 Walkthrough

The X-WPAC-ERROR branch no longer passes commentUrl to its debug call before the variable is declared.

Changes: AJAX error handling

Layer / File(s) Summary
Remove premature debug argument
src/js/frontend/wp-ajaxify-comments.js
The error-state debug call no longer references commentUrl before its declaration.

Priority: ⚪ Not assessed

Estimated code review effort: 1 (Trivial) | ~3 minutes

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 6e1c9

The validation-error fix is present in the shipped assets, with no identified issue preventing merge after normal checks.

Pre-merge checks: Passed 5
Passed Passed checks: 5 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly describes the main change: fixing AJAX validation-error response handling caused by premature commentUrl access.
Linked Issues check Passed Issue #79 requires removal of the premature commentUrl access while preserving error handling and normal comment behavior. The source change removes that debug argument. The PR summary reports regen…
Out of Scope Changes check Passed The reported changes are limited to the source fix and the four generated frontend assets listed by issue #79. The generated assets support the source change. The PR reports no dependency, server-side…
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@superdav42
superdav42 force-pushed the feature/auto-20261015-022352-gh79 branch from a2f2645 to 7f62418 Compare October 15, 2026 08:42
@superdav42

superdav42 commented Oct 15, 2026 •

Copy link
Copy Markdown
Collaborator Author

Completion Summary

  • What: Remove the premature commentUrl debug argument from the HTTP-success X-WPAC-ERROR branch, allowing existing validation-error handling and completion cleanup to run.
  • Issue: fix: AJAX validation-error responses throw before displaying the error #79
  • Final head: 6e1c9a0ad29bd2c3122bffb1ed5aacd24c7789cd.
  • Files changed: src/js/frontend/wp-ajaxify-comments.js, dist/wpac-frontend-js.js, dist/wpac-frontend-js.asset.php, dist/wpac-frontend-wp-ajaxify-comments.js, dist/wpac-frontend-wp-ajaxify-comments.asset.php.
  • Testing: Existing frontend ESLint with zero warnings, production webpack build, Node syntax checks for source and both bundles, PHP syntax checks for both asset manifests, and branch whitespace checks passed. Ten browser flows passed across the source and both production bundles: 2xx error-header responses with debug off/on, non-2xx validation responses, cleared submitting guards, and a corrected real WordPress POST with the ordinary awaiting-moderation success path. No JavaScript exceptions occurred during those final ten flows. The runtime-tested revision was a2f2645d1ddc366c8be9063585d78c105b56aa4f; all five delivered file blobs are identical at the final head, and lint/syntax checks were repeated there. Independent supplied-source review found no introduced P0/P1 defect.
  • Runtime coverage limit: The existing WordPress 6.8.2 local site had no deployed Ajaxify server plugin. Current frontend assets ran on its real comment page; one-shot DevTools overrides supplied status/header metadata while retaining actual WordPress response bodies and real POST handling. This is changed-frontend-path verification, not an unmodified server-plugin integration run or reproduction of the historical support report.
  • Key decisions: Preserve existing error extraction, success behavior, and server validation policy. Regenerate only the scoped frontend assets; no dependency, repository test-infrastructure, fixture, or CI changes. Untouched Sass/Babel deprecation warnings remain outside scope. The local test comment was reversibly trashed after verification, and the temporary asset server and browser were stopped.

aidevops.sh v3.39.27 plugin for OpenCode v1.19.0 with gpt-6.1-sol spent 22m and 175,182 tokens on this as a headless worker.

@ultimate-multisite ultimate-multisite Bot added the status:in-review Non-draft PR ready for review/merge label Oct 15, 2026
@superdav42
superdav42 marked this pull request as ready for review October 15, 2026 08:48
@superdav42
superdav42 merged commit 3854939 into main Oct 15, 2026
2 of 3 checks passed
@superdav42 superdav42 added status:done Task is complete and removed status:in-review Non-draft PR ready for review/merge labels Oct 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

origin:worker Created by headless/pulse worker session status:done Task is complete

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: AJAX validation-error responses throw before displaying the error

1 participant