GH#883: handle WP_Error array payloads in network-activate error handler#886
GH#883: handle WP_Error array payloads in network-activate error handler#886superdav42 merged 1 commit intomainfrom
Conversation
When a WP_Error is serialized as JSON in an AJAX response, WordPress can return response.data as an array of error objects rather than a plain object with a .message property. Previously the error handler only checked response.data.message, so array-type WP_Error payloads fell through to the generic fallback message. Now the handler first checks Array.isArray(response.data) and extracts the message from the first element (response.data[0].message), then falls back to response.data.message for plain-object errors, and finally falls back to wu_network_activate.error_message. Guards are in place for missing array elements and missing fields to avoid runtime errors. Resolves #883
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 30 minutes and 38 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Completion Summary
|
🔨 Build Complete - Ready for Testing!📦 Download Build Artifact (Recommended)Download the zip build, upload to WordPress and test:
🌐 Test in WordPress Playground (Very Experimental)Click the link below to instantly test this PR in your browser - no installation needed! Login credentials: |
|
Performance Test Results Performance test results for 201ee0f are in 🛎️! Note: the numbers in parentheses show the difference to the previous (baseline) test run. Differences below 2% or 0.5 in absolute values are not shown. URL:
|
Summary
Handle WP_Error serialized array payloads in the network-activate AJAX error handler.
When WordPress serializes a
WP_Errorto JSON viawp_send_json_error(), it canproduce
response.dataas either:.messageproperty, or.messageproperty)The previous handler only covered the plain-object case. This fix adds detection for
the array case (
Array.isArray(response.data)), safely extracts the message fromresponse.data[0].message, and falls back gracefully through:response.data[0].messageresponse.data.messagewu_network_activate.error_messageAll missing element/field guards are in place to prevent runtime errors.
Files Changed
assets/js/network-activate.js:46-54— updated error message extraction logicRuntime Testing
Key Decisions
Array.isArray()check (notinstanceof Array) for cross-frame compatibilityresponse.data.length > 0 && response.data[0] && response.data[0].messageprevent all runtime errors on sparse/malformed arraysvar, alignment spaces, JSDoc tags) are untouched — they predate this PRResolves #883
aidevops.sh v3.8.56 plugin for OpenCode v1.4.6 with claude-sonnet-4-6 spent 3m and 4,211 tokens on this as a headless worker.