fix(commerce-onboarding): don't skip site re-claim on a malformed siteUrl param#4483
Merged
pedrofrxncx merged 1 commit intoJul 13, 2026
Merged
Conversation
…eUrl param The site-match check added in #4439 (re-claim the connection when the requested site differs from the one it's currently claimed for) bypassed itself whenever normalizeCommerceSiteUrl failed — which happens both for an empty requestedSite (intentional: no site requested, trust the existing claim) and for a non-empty but malformed one (unintentional). A garbled ?siteUrl query param therefore skipped re-claiming and skipped the COMMERCE_DISCOVERY_RUN trigger, opening whatever site the connection happened to already be claimed for instead of surfacing the invalid-URL error the rest of the component already handles. Extracted the check into isConnectionClaimedForSite so "no site requested" and "invalid site requested" are distinguished explicitly, and added a regression test for the malformed-but-non-empty case.
pedrofrxncx
enabled auto-merge (squash)
July 13, 2026 13:24
pedrofrxncx
deleted the
fix/commerce-onboarding-malformed-site-url-reclaim
branch
July 13, 2026 13:35
decocms Bot
pushed a commit
that referenced
this pull request
Jul 13, 2026
PR: #4483 fix(commerce-onboarding): don't skip site re-claim on a malformed siteUrl param Bump type: patch - decocms (apps/mesh/package.json): 4.11.14 -> 4.11.15 Deploy-Scope: both
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.
Source
Bug found while reading the most recently merged commit on
main(#4439, "GitHub companion repo search + re-claim site on report open"), which added a check to re-claim the Commerce Discovery connection when the requested site differs from the one it's currently claimed for.The bug
normalizeCommerceSiteUrlreturns{ ok: false }both for an empty input and for a non-empty but malformed one. The new check used!requestedNormalized.okto mean "no site was requested, trust the existing claim" — but that condition is also true for a malformed, non-empty site param, which was never the intent.Failure scenario
https://a.com(connection's claimed site =a.com).?siteUrl=param (e.g. a corrupted/edited link) for a different site.claimedForRequestedSiteevaluates totrueregardless of which site is actually claimed, sosetupReadybecomestrue.triggerInitialSetup) never fires, andopenReportskips theCOMMERCE_DISCOVERY_RUNtrigger entirely (since the malformed URL failsnormalizeCommerceSiteUrlagain there) — it just opens whatever report the connection happens to already point at, instead of surfacing the invalid-URL error the rest of the component already handles for this exact case (see theinitialSiteUrlnormalization branch further down).This silently defeats the wrong-store-diagnostic fix #4439 just added.
Fix
Extracted the check into
isConnectionClaimedForSite(requestedSite, claimedSiteUrl)insite-url.ts, which explicitly distinguishes "no site requested" (empty string) from "invalid site requested" (non-empty, fails normalization) — only the former bypasses the match check.Test
Added
isConnectionClaimedForSiteunit tests insite-url.test.ts, including a regression test for the malformed-non-empty case that fails on the old inlined logic and passes with the fix.Verify
Checks run locally
bun run fmtbunx tsc --noEmitinapps/mesh(pre-existing unrelated errors confirmed present onmainbefore this change too; no new ones introduced)bun test apps/mesh/src/commerce-discovery/site-url.test.ts— 17 passFull CI will run the broader suite/lint.
Summary by cubic
Fixes Commerce onboarding so a malformed non-empty
siteUrlno longer bypasses site re-claim and skipCOMMERCE_DISCOVERY_RUN. EmptysiteUrlis treated as “no site requested,” while invalid non-empty values now trigger a re-claim or surface the existing invalid-URL error.isConnectionClaimedForSite()to distinguish empty vs invalidsiteUrland compare normalized origins.commerce-onboarding.tsxto use this helper instead of inline checks.Written for commit 18a428c. Summary will update on new commits.