fix(broken-links): prefer parent-path over homepage fallbacks and block record-ID sibling suggestions#2576
Open
jsanchez07 wants to merge 5 commits into
Open
fix(broken-links): prefer parent-path over homepage fallbacks and block record-ID sibling suggestions#2576jsanchez07 wants to merge 5 commits into
jsanchez07 wants to merge 5 commits into
Conversation
Contributor
|
This PR will trigger no release when merged. |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
noruiz
reviewed
Jun 1, 2026
Comment on lines
+208
to
+211
| } else if ( | ||
| nonRootSuggestedUrls.length === 0 | ||
| && filteredSuggestedUrls.length > 0 | ||
| && !filteredSuggestedUrls.includes(nextSuggestedUrls[0]) |
Contributor
There was a problem hiding this comment.
This also fires when we fell back to existing suggestions from a prior run which wipes existingData.aiRationale even though it's still valid. Consider moving aiRationale = undefined into the if (parentFallback) branch instead.
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.
Problem
When Mystique cannot access site content (e.g. no scraped pages cached for the domain),
it falls back to suggesting the site's homepage. That suggestion passes all existing
validation (same domain, returns 200) but gives users no useful redirect target — it just
dumps visitors at the root.
A second related problem: for broken URLs with numeric or prefixed-numeric slugs
(
/event-schedule/917,/events/ticketevent-1226947352), Mystique sometimes suggestsa sibling record at the same path depth. Those records are equally deleted — or unrelated
— so the suggestion is wrong regardless of how good the path overlap looks.
Changes
src/utils/url-utils.jslooksLikeRecordId(slug)(new private helper): returnstruefor pure-numeric slugs(
"917") and prefixed-numeric slugs ("ticketevent-1226947352").isEntityReplacementSuggestion: extended to cover record-ID broken slugs.event-schedule/917→event-schedule/2671).(e.g.
events/babymetalrejected,events/event-schedule/kept).the person-entity logic.
src/broken-links-guidance/guidance-handler.jsnonRootSuggestedUrlsfilter: afterfilterBrokenSuggestedUrls, drops any URLwhose pathname is
/or"". Mystique's homepage fallback passes the existing HTTPcheck (200) but is never a useful redirect target.
nonRootSuggestedUrlsis empty:resolveParentPathFallback— walk up the broken URL one level at a time andreturn the first parent that responds 200. Never tries the root.
(may be intentional — entire section removed).
effectiveBaseURL.aiRationaleclearing: when a homepage is replaced by a parent path, Mystique'srationale (which was written about the homepage) is dropped so it does not mislead
users about why the parent path was chosen.
Safety properties
resolveParentPathFallbacknever tries root, so/some-page→ returns null → homepage suggestion is preserved.reused and the fallback chain is never entered.
Test plan
resolveParentPathFallbackreturns first live parent, skips 404 parents, returnsnull when all parents 404 or broken URL has depth 1
isEntityReplacementSuggestionrejects same-depth and sibling-of-parent record-IDsuggestions; keeps the immediate parent directory suggestion
aiRationaleis cleared on homepage→parent-path replacement, preserved otherwise