Repository navigation
Guide the WooCommerce setup and flag keys refused again and again - #1634
Merged
Merged
Conversation
- WooCommerce address: cleaned silently (https, no /wp-admin, /wp-json, /wp-login.php, query or trailing slash), then asked without a key at /wp-json/: WordPress's own address is used and handed back as `corrected`; missing WooCommerce, a version below 3.5, Plain permalinks (with the Settings -> Permalinks link), Cloudflare and security-plugin blocks (naming EGRESS_IPS on Cloud, "the address of your AnythingMCP server" on self-hosted), DNS, certificate and http-only answers get their own text. Used by the setup check, the install probe, the chat install and setup_get_status. - WooCommerce 401s told apart (woocommerce_rest_cannot_view vs an unknown key) in the setup check and at call time. - Repeated 401s on read tools of a connector with a stored key are recorded as its credential status (dashboard, setup_get_status), without an email; a working call or an edit clears it. - setup_get_status points out catalog connectors still waiting for their values after 24 hours and asks the assistant to offer the new link.
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Summary
WooCommerce setups mostly fail before the key matters. 28 of the 41 WooCommerce connectors that never made a call were chat installs still holding
{{WOOCOMMERCE_URL}}. Most failed checks were a wrong address, Plain permalinks or a Cloudflare challenge, and all of them got the same "No WooCommerce REST API" message. Separately, one connector answered 401woocommerce_rest_cannot_viewfor three days, up to 145 times a day, and nothing on the dashboard showed it.This PR covers items M4 (step 1 of the guided setup), M7 (repeated-401 signal) and the in-app part of M6 (no emails) from the WooCommerce plan. It builds on #1631.
Changes
adapters/woocommerce-setup.ts(new):normalizeWooCommerceUrl: trims the value, sets https, and cuts/wp-json…,/wp-admin…,/wp-login.php,index.php, the query, the fragment and trailing slashes. A subfolder install is kept.discoverWooCommerce: unauthenticated GETs throughoutboundRequest(same SSRF policy and per-redirect checks as the other setup checks; private IPs give no answer), with an 8 s timeout, asking only for?_fields=home,namespaces. It works out:home), returned ascorrected;wc/v3is present (WooCommerce inactive, or older than 3.5);/wp-json/but?rest_route=/answers. The text names Settings → Permalinks and links…/wp-admin/options-permalink.php;final: the check stops before the key is sent.woocommerce_rest_cannot_viewvswoocommerce_rest_authentication_error).NORMALISERS.woocommerceinenv-var-checks.ts. It runs on import, verify, the variable editor and the chat install;normalizeAdapterEnvValuegets an optionalslugfor that.AdaptersService.checkCredentials): discovery runs before the probe.homereplaces the typed address and comes back ascorrected+note; the setup page already writescorrectedinto the field and saves it, so there is no frontend change. A failure gets the WooCommerce-specific text in place of the generic hint.runImportProbe): the same advice on failure.ConnectorSetupService.install, likecheckOdooAddress):homeand reports it incheckedTheAddress;connectors/engines/credential-refusal-tracker.ts+DynamicMcpTools.ConnectorAuthStatusService.mark(needs_reauth, code credential_refused)with the new{ notify: false }, so no email. The incident counts as already told, so later marks send nothing either.auth-status.tsx) shows it.setup_get_status:credential: { ok: false, since, message }+fixUrl+credentialHintfor a ready connector markedneeds_reauth;unfinishedSince+unfinishedHintfor a catalog connector stillneeds_input24 h after creation. The assistant offers the freshfinishSetupUrl(already returned for every unfinished connector) or asks whether to remove it.error-hints.ts: WooCommerce 401 rule at call time (the same two texts), with the connector page link.Type
Cloud vs self-hosted
The behaviour is the same in both modes. Only the firewall text differs:
EGRESS_IPS("AnythingMCP Cloud's address 104.248.242.235" when set).EGRESS_IPSis set.Discovery follows the instance's SSRF policy, so a self-hosted install that allows private addresses can check an intranet shop.
No Prisma change (M7 uses the existing
auth_status*columns), no emails, nothing underee/, no new endpoint or DTO (no new input). Every query keeps itsorganizationIdscope.Testing
Commands (worktree with node_modules symlinked to the main checkout;
DATABASE_URL=postgresql://x:x@localhost:5433/x npx prisma generatefirst), all inpackages/backend:npm run lint: 0 errors, 11 warnings, all in files this PR does not touch. No files rewritten.npx tsc --noEmit -p tsconfig.json: no errors from this change. The only errors are the local checkout's missing@types/picomatch,@aws-sdk/*,basic-ftpandssh2(present in CI).npx jest --maxWorkers=4on the touched and new suites (woocommerce-setup,adapters.service.woocommerce-verify,connector-setup.service,env-var-checks,error-hints*,credential-refusal-tracker,connector-auth-status.service,dynamic-mcp-tools.credential-refused): all pass. Locally I used a jest config that maps the missing SDK modules to a stub; CI has them.auth/jwt-or-management-key.guard.spec.tsneeds a live Postgres;ee/file-search/sources/sources.spec.tsneeds the real S3/FTP/SSH SDKs that were stubbed.Manual:
discoverWooCommerceagainst real public sites (read-only GETs, no keys), 11 Nov 2026:wpbeginner.comhomehttps://www.wpbeginner.com, nowc/v3→ "WooCommerce is not active"https://woocommerce.com/wp-admin/https://woocommerce.comhttp://woocommerce.com/products/woocommerce-subscriptions/correctedhttps://woocommerce.comhttps://www.nalgene.com/shop/correctedhttps://nalgene.comhttps://www.porterandyork.comhttps://jetpack.com,https://example.comhttps://no-such-shop-xyz-4711.comhttps://expired.badssl.comCERT_HAS_EXPIRED), finalhttps://192.168.1.10Also confirmed:
GET https://woocommerce.com/wp-json/wc/v3/orders?per_page=1without a key answers 401woocommerce_rest_cannot_view. So that code also means the key was not seen at all, and the hint says so: the key's user lacks rights, or WordPress does not know it runs on https (WooCommerce then ignores keys in the query string).Notes / open points
/wp-jsonand/wp-admincan no longer be stored. But the setup page checks the pattern in the browser before sending, without the normaliser. A tighter pattern would refusehttps://shop.com/wp-admin/with a manual "remove /wp-admin" fix instead of cleaning it silently, and would suggest cutting a subfolder install's folder. Tightening would need the same normaliser infrontend/src/lib/address-fix.ts.verifyHints["403"]inwoocommerce.jsonstill names 104.248.242.235. That text now only shows when discovery found nothing (discovery's own blocked text usesEGRESS_IPS). I did not touchwoocommerce.jsonto stay clear of the compact-defaults PR.{ notify: false }), but that is customer contact, so it is left off.unfinishedSinceonly when it callssetup_get_status. Nothing pushes it into other tool answers or instructions;needsSetupin the connections list already carries the link.docs/catalog/connectors/woocommerce.mdis generated by the website repo.Checklist
npm test) — see Testing for the two suites that only fail locallyRelated Issues
Follows #1631. Items M4, M6 (in-app part) and M7 of the WooCommerce plan of 11 Nov 2026.