Skip to content

Fix bad URL when pattern refers to empty singular relationship - #433

Open
jorrit wants to merge 4 commits into
pluginpal:masterfrom
jorrit:missingrelationalfields
Open

Fix bad URL when pattern refers to empty singular relationship#433
jorrit wants to merge 4 commits into
pluginpal:masterfrom
jorrit:missingrelationalfields

Conversation

@jorrit

@jorritjorrit commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

What does it do?

Since 661a844 I experience bad friendly urls when the pattern contains a reference to an optional manyToOne field and the field is empty.

Why is it needed?

My pattern is /over/[parent_page.slug]/[slug].
When my page contains no parent_page, the resulting friendly URL becomes /over/[parent_page.slug]/cookies instead of /over/cookies.
In addition, the following is logged to the server log:
Something went wrong whilst resolving the pattern.

How to test it?

Create a content type with a manyToOne or One to One relationship.
Refer to this relationship in the URL pattern.
Generate the URL for an entity where this relationship is empty.

@changeset-bot

changeset-botBot commented Jun 29, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: abd1535

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
NameType
strapi-plugin-webtoolsPatch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@jorrit
jorritforce-pushed the missingrelationalfields branch from 2dd2800 to 254cc2cCompareJune 29, 2026 11:37
@jorritjorrit changed the title Add test to demonstrate issue with pattern to missing relationFix bad URL when pattern refers to empty singular relationshipJun 29, 2026
@jorrit
jorritforce-pushed the missingrelationalfields branch from 254cc2c to abd1535CompareJune 29, 2026 11:41
@jorrit

jorrit commented Jun 29, 2026

Copy link
Copy Markdown
ContributorAuthor

I have rewritten the error message to make it more specific for the single instance in which it applies: a reference to a manytomany relationship without an index. I would suggest that in that case the index 0 is used. In that case, there will never be a situation that is unhandled.

@jorrit
jorrit marked this pull request as ready for review June 29, 2026 11:46
@codecov

codecovBot commented Jun 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 34.60%. Comparing base (94a5e0e) to head (abd1535).
⚠️ Report is 8 commits behind head on master.

Additional details and impacted files
@@ Coverage Diff @@## master #433 +/- ##
==========================================
- Coverage 34.73% 34.60% -0.14% 
==========================================
Files 2 2 Lines 763 763 Branches 192 189 -3 ==========================================
- Hits 265 264 -1 - Misses 397 400 +3 + Partials 101 99 -2 
FlagCoverage Δ
unit34.60% <ø> (-0.14%)⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jorrit

Copy link
Copy Markdown
ContributorAuthor

@boazpoolman can you take a look?

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@jorrit