Repository navigation
Fall back to bundled schemas when the remote schema download fails - #519
Conversation
WP_CLI\Utils\http_request() throws a RuntimeException on transport errors even with halt_on_error set to false, so remote_get() aborted make-pot instead of returning an empty string and using the bundled block-i18n.json / theme-i18n.json fallbacks. Fixes #518. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UWTd5ocijEgHN4xLrNgcUG
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Handle failed schema downloads src/JsonSchemaExtractor.php, features/makepot.feature |
remote_get catches RuntimeException, logs the URL and exception message, and returns an empty string. The feature scenario checks fallback debug output and POT generation when remote schema downloads return HTTP 503. |
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix · Severity of issue fixed: Medium
Suggested reviewers: schlessera
Merge Risk: 
Minimal · up to c54d2
-
The schema fallback and offline test path are supported, with no actionable merge-blocking risk established.
Pre-merge checks: 
5
-
Full details: Linked Issues check
-
Explanation
Issue
#518requiresmake-potto handle the transportRuntimeException, log a debug message, return an empty string, and use the bundled schema.src/JsonSchemaExtractor.phpimportsRuntimeException.remote_get()catches it, logsFailed to download from URL ..., and returns''.load_schema()then logs the fallback message and reads the bundled schema. The addedmake-potBehat scenario verifies successful POT generation and extraction from block and theme JSON files under a failed schema request.
Full details: Out of Scope Changes check
-
Explanation
The production change directly implements issue
#518. Thefeatures/makepot.featurechange is an automated regression test for the remote-schema failure and bundled-schema fallback. No unrelated production behavior or unrelated files are shown in the reviewed changes.
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 1 files. (1 skipped: 1 unsupported.)
-
Finishing Touches
-
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.
CodeRabbit Verify
- Run CodeRabbit Verify to test the changes in this pull request.
There was a problem hiding this comment.
Copilot code review could not start because the generated Actions workflow failed validation. Check .github/workflows/copilot-code-review.yml (or .yaml) on your default branch, or copilot-setup-steps.yml (or .yaml) if the code review workflow is absent. Check action references and the placement of workflow settings. If the configuration is valid, or you have no setup workflow, contact GitHub Support.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
cURL ignores the configured proxy for hosts matched by NO_PROXY/no_proxy, so an inherited NO_PROXY=* would let the schema downloads succeed and break the scenario's assertions. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UWTd5ocijEgHN4xLrNgcUG
Replace the unreachable-proxy require file with the built-in "Given that HTTP requests to ... will respond with" step. A mocked response without a header/body separator makes Requests throw, which http_request() turns into a RuntimeException, so the scenario exercises the fixed code path without network access, proxy env vars or retries. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UWTd5ocijEgHN4xLrNgcUG
Fixes #518.
JsonSchemaExtractor::remote_get()passeshalt_on_error => falsetoWP_CLI\Utils\http_request()and expects an empty string on failure, so the bundledblock-i18n.json/theme-i18n.jsoncopies are used. But on transport errorshttp_request()throws aRuntimeExceptioneven whenhalt_on_erroris false, which abortedmake-potwithout writing a POT file.This PR catches that exception in
remote_get(), logs a debug message, and returns''so the existing fallback runs.Verification
Ran
wp i18n make-poton a plugin with ablock.jsonandtheme.json, both with requests forced through an unreachable proxy and with a mocked malformed response:Error: Failed to get url 'https://develop.svn.wordpress.org/trunk/src/wp-includes/block-i18n.json': …, exit 1, no POT.Failed to download from URL …/Remote file could not be accessed, will use local file as fallback,Success: POT file successfully generated., and the POT contains the block title and theme.json color-name strings.Tests
Added a Behat scenario in
features/makepot.featurethat uses the wp-cli-testsGiven that HTTP requests to … will respond with:step. The mocked response has no header/body separator, so Requests throws andhttp_request()raises the sameRuntimeExceptionas on a network error. A well-formed error response (e.g. a 500) would not cover this, since it takes the already-working! $response->successbranch. The scenario fails without the fix and needs no network access.🤖 Generated with Claude Code
https://claude.ai/code/session_01UWTd5ocijEgHN4xLrNgcUG
Summary by CodeRabbit