Repository navigation
Stop failed Commerce Partner Integration calls from breaking the daily sync and feed uploads - #4070
Open
jczhuoMeta wants to merge 1 commit into
Open
jczhuoMeta wants to merge 1 commit into
jczhuoMeta wants to merge 1 commit into
Conversation
Contributor
📦 Latest Plugin BuildBuilt at: 2026-11-05T10:26:21Z Download: Click here to download the plugin To download: Click the link above → Scroll to bottom → Download "facebook-for-woocommerce" artifact |
jczhuoMeta
force-pushed
the
fix/cpi-graceful-failures
branch
from
September 30, 2026 20:03
5e87635 to
4d77957
Compare
jczhuoMeta
force-pushed
the
fix/cpi-graceful-failures
branch
from
October 13, 2026 19:37
4d77957 to
297f51f
Compare
11 tasks done
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #4070 +/- ##
=======================================
Coverage ? 11.11%
Complexity ? 6135
=======================================
Files ? 235
Lines ? 20786
Branches ? 0
=======================================
Hits ? 2310
Misses ? 18476
Partials ? 0
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
jczhuoMeta
marked this pull request as ready for review
October 13, 2026 22:29
|
@jczhuoMeta has imported this pull request. If you are a Meta employee, you can view this in D125257831. |
…y sync and feed uploads A repair response or legacy FBE install read that encoded its ID as a number made Repair\Response::get_commerce_partner_integration_id() or FBE\Installation\Read\Response::get_catalog_id() throw a TypeError under strict_types. The error escaped the ApiException handler and aborted the rest of the daily sync, skipping the configuration push and asset refresh. Both getters now accept string or integer IDs and treat any other type as missing. The legacy FBE install read reported a successful refresh even when Graph returned an error or no installation at all. Both cases now raise, so the existing handler records the failure and no stored asset changes. file_update Graph errors were silently discarded; they are now logged like any other upload failure. CPI metadata feeds kept regenerating and failing to upload when the store had no access token, for example after a rejected finalize-install cleared the token but left the stored IDs. They are now skipped until the store is connected again. The feed callback used to regenerate a missing file through generate_feed_file(), which announces a new feed and starts another upload, and did so before checking the secret. Any request to the callback, or Meta fetching a file whose write kept failing, could re-trigger uploads. The secret is now checked first, in constant time and only against a string, and a missing file is rebuilt in place without starting a new upload. Invalid-secret requests still get a 401 but are no longer logged to Meta, so anonymous requests cannot flood the log queue.
vahidkay-meta
force-pushed
the
fix/cpi-graceful-failures
branch
from
November 5, 2026 10:25
297f51f to
1151367
Compare
This branch has not been deployed
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.
Description
Hardens the plugin's Commerce Partner Integration (CPI) and feed-upload calls so that one failing call cannot affect more than itself. Two deliberate behaviors are unchanged:
wc_facebook_connection_invaliddetection (API::do_post_parse_response_validation)This PR is independent of #4058. Both add to
tests/e2e/plugin-level-tests.spec.jsin different places, and they merge cleanly ontomainin either order.Internal tracking: T292702689
1. A numeric ID aborts the daily sync.
Repair\Response::get_commerce_partner_integration_id()andFBE\Installation\Read\Response::get_catalog_id()are declared understrict_types. A numeric ID in the response made them throw aTypeError. That error got past theApiExceptionhandler and skipped the rest ofrefresh_installation_data(), including the configuration push and asset refresh. Both getters now accept string or integer IDs and treat any other type as missing.2. Failures reported as success.
The legacy FBE install read logged "Refreshed asset mapping…" even when Graph returned an error or no installation. Both cases now raise, and the existing handler records the failure. No stored asset changes.
file_updateGraph errors were silently discarded. They are now logged like other upload failures.3. CPI metadata feeds run without an access token.
AbstractFeed::should_skip_feed()only checked the stored CPI and CMS IDs. A rejected finalize-install clears the token but leaves those IDs, so the promotions, shipping, navigation and ratings feeds kept regenerating and failing their upload. Feeds are now skipped until the store is connected again.4. The feed callback can re-trigger uploads.
The
?wc-api=wc_facebook_get_feed_data_*callback regenerated a missing file withgenerate_feed_file(), which announces a new feed and starts anotherfile_updateupload. It did this before checking the secret. So any request, or Meta fetching a file whose write kept failing, could keep re-triggering uploads. Now the callback:hash_equals()) and only against a string value;It also replaces non-public service and class names in comments and test strings of the touched files with the public endpoint names.
Type of change
Checklist
Changelog entry
Stop failed Commerce Partner Integration calls from breaking the daily sync and feed uploads.
Test Plan
Automated
PHP unit suite (PHP 8.2): 2116 tests passed. New and updated tests:
RepairResponseTest(new) andReadInstallationResponseTest: string, int, array, null, float and bool IDs for both getters.ConnectionCpiRepairTest::test_repair_accepts_numeric_integration_idandConnectionAssetMappingTest::test_fbe_install_read_accepts_numeric_catalog_id: the daily sync completes with numeric IDs.ConnectionAssetMappingTest::test_fbe_install_read_error_is_not_reported_as_refresh: Graph error, "no install" and "empty install" responses.AbstractFeedTest: no-token skip case, andtestUploadGraphErrorIsLogged.New e2e test,
plugin-level-tests.spec.js: "Feed callback checks the secret before rebuilding a missing feed file". It moves the promotions feed file aside, then checks that:The unit tests cannot cover this ordering because the callback ends with
exit;. It runs in CI'splugin-eventsgroup and passes.PHPCS (
phpcs.xml.dist) and PHPCompatibilityWP (PHP 7.4+) on changed files,php -l,node --checkandgit diff --check: clean.Manual verification
wc_facebook_access_tokenbut keep the CPI and CMS IDs. Run the promotions feed's scheduled action and confirm there is nofile_updaterequest and nofeed_uploaderror log. Restore the token and confirm the next scheduled run uploads.wp-content/uploads/facebook_for_woocommerce/promotions/. Request?wc-api=wc_facebook_get_feed_data_promotions&secret=wrong: expect a 401, no file regeneration, nofile_updaterequest, and no Meta log. Repeat with the real secret fromwc_facebook_feed_url_secret_promotions: expect the file to be rebuilt and served, still with nofile_updaterequest.QA results
Local WordPress store (WordPress 7.1.2, WooCommerce 11.1.2, PHP 8.2.30), 2026-10-13. The PHP debug log had no new warnings or fatal errors during any of the checks below, including heartbeats run through WP-Cron.
should_skip_feed()returned true, nothing was scheduled, and no HTTP request was made. With the token restored, the feed was no longer skipped, andPOST /{cpi_id}/file_updatereturned 200.Screenshots
Not applicable; this change has no user-interface impact.