Skip to content

fix: strip language prefix from full_slug when Translatable Slugs app is not installed - #119

Merged
silasjoisten merged 2 commits into
1.xfrom
fix/language-prefixed-full-slug
Aug 5, 2026
Merged

fix: strip language prefix from full_slug when Translatable Slugs app is not installed#119
silasjoisten merged 2 commits into
1.xfrom
fix/language-prefixed-full-slug

Conversation

@silasjoisten

Copy link
Copy Markdown
Collaborator

Problem

When a story is fetched with the ?language= parameter and the Translatable Slugs app is not installed in the space, the Content Delivery API returns:

  • default_full_slug: null
  • full_slug: prefixed with the requested language, e.g. en/about-us

ResolveControllerListener uses $story['default_full_slug'] ?? $story['full_slug'] and feeds that slug back into StoriesApi::bySlug() for its second fetch (when the controller declares resolveRelations/resolveLinks) and into the controller registry slug lookup. The API does not know the language-prefixed slug and responds with 404 — so every non-default-locale page whose controller declares resolveRelations or resolveLinks throws a StoryNotFoundException, while the default locale keeps working (its full_slug is never prefixed).

With ascending_redirect_fallback enabled the symptom is even more confusing: the fallback then requests the parent slug (usually a folder) and surfaces its 404, e.g. HTTP/2 404 returned for "https://api.storyblok.com/v2/cdn/stories/raeume?language=en".

Fix

When default_full_slug is null and the story's lang is not default, strip the {lang}/ prefix from full_slug before the slug is reused. Spaces with the Translatable Slugs app installed are unaffected (default_full_slug takes precedence as before).

Testing

  • New regression test: story with default_full_slug: null, full_slug: "en/…", lang: "en" and a controller declaring resolveLinks — asserts both bySlug() calls receive the unprefixed slug and the controller still resolves by slug.
  • Full suite green (512 tests), PHPStan clean (one baseline count adjusted for the new test).
  • Verified end-to-end against a real space without Translatable Slugs: all non-default-locale pages 404 before, 200 after.

🤖 Generated with Claude Code

… is not installed

Stories fetched with ?language= return a language-prefixed full_slug
("en/about-us") when the Translatable Slugs app is not installed
(default_full_slug is null). ResolveControllerListener fed that prefixed
slug back into StoriesApi::bySlug() for its second fetch (link/relation
resolving), which the Content Delivery API answers with 404 - breaking
every non-default-locale page whose controller declares resolveLinks or
resolveRelations.
@codecov-commenter

codecov-commenter commented Aug 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.32%. Comparing base (eb0cb4f) to head (249f9c6).

Additional details and impacted files
@@             Coverage Diff              @@
##                1.x     #119      +/-   ##
============================================
+ Coverage     94.30%   94.32%   +0.01%     
- Complexity      476      480       +4     
============================================
  Files            54       54              
  Lines          1493     1498       +5     
============================================
+ Hits           1408     1413       +5     
  Misses           85       85              

☔ 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.

Data-provider test pinning the slug used for the second story fetch:
with the app installed (default_full_slug wins, even for translated
slugs), without the app (language prefix stripped, incl. nested slugs),
and the edge cases: unprefixed full_slug for a non-default language,
missing lang key, and a real story path whose first segment equals a
language code.
@silasjoisten
silasjoisten merged commit 91ef206 into 1.x Aug 5, 2026
4 checks passed
@silasjoisten
silasjoisten deleted the fix/language-prefixed-full-slug branch August 5, 2026 11:29
Sign up for free to 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.

2 participants