Skip to content

Derive page path prefixes from the root page, not the instance id - #286

Open
bbliem wants to merge 1 commit into
fix/repair-page-slugs-revisionsfrom
fix/page-path-prefix-symmetry
Open

Derive page path prefixes from the root page, not the instance id#286
bbliem wants to merge 1 commit into
fix/repair-page-slugs-revisionsfrom
fix/page-path-prefix-symmetry

Conversation

@bbliem

@bbliem bbliem commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

resolve_url_path stripped ^/<instance-id>(-[0-9]+)?/ off a page's url_path, while resolve_page prepended the translated root page's url_path to the path it was handed. Both directions of the same round trip, taking the prefix from two different places, agreeing only while the root page's slug equalled the identifier -- an invariant nothing in the codebase maintained. When it broke, the front page kept resolving (its relative path is empty either way) while every child 404ed, which is what made both incidents read as a content problem rather than a routing one.

The two conversions now live next to each other in pages/url_paths.py and both take the prefix from the root page's own url_path, so a slug that disagrees with the identifier can no longer separate them. The regex and its FIXME go with it, along with the special case for translated roots: their numeric suffix is now just a Wagtail sibling-uniqueness requirement, not something routing has to know about.

_create_default_pages found the root page by slug=self.identifier, so a drifted slug meant it found nothing and built a second root page beside the real one. That orphan is what left augsburg-bisko with a duplicate, and what put a stale page in a position to hold the slug longmont needed. The lookup now keys on the root_page FK, which survives a rename, and falls back to the slug only for instances whose FK was never populated. _create_instance_root_page gets the same treatment; it used to add_child unconditionally on every sync.

repair_instance_page_slugs keeps its reason to exist -- the revision pass, and slug hygiene -- but its docs no longer claim a mismatched slug breaks routing, because it no longer does.

test_page_routing.py round-trips pages -> urlPath -> page(path:) through the real schema against a drifted slug, and fails on the previous resolvers.

resolve_url_path stripped `^/<instance-id>(-[0-9]+)?/` off a page's
url_path, while resolve_page prepended the translated root page's url_path
to the path it was handed. Both directions of the same round trip, taking
the prefix from two different places, agreeing only while the root page's
slug equalled the identifier -- an invariant nothing in the codebase
maintained. When it broke, the front page kept resolving (its relative path
is empty either way) while every child 404ed, which is what made both
incidents read as a content problem rather than a routing one.

The two conversions now live next to each other in pages/url_paths.py and
both take the prefix from the root page's own url_path, so a slug that
disagrees with the identifier can no longer separate them. The regex and its
FIXME go with it, along with the special case for translated roots: their
numeric suffix is now just a Wagtail sibling-uniqueness requirement, not
something routing has to know about.

_create_default_pages found the root page by `slug=self.identifier`, so a
drifted slug meant it found nothing and built a second root page beside the
real one. That orphan is what left augsburg-bisko with a duplicate, and what
put a stale page in a position to hold the slug longmont needed. The lookup
now keys on the root_page FK, which survives a rename, and falls back to the
slug only for instances whose FK was never populated.
_create_instance_root_page gets the same treatment; it used to add_child
unconditionally on every sync.

repair_instance_page_slugs keeps its reason to exist -- the revision pass,
and slug hygiene -- but its docs no longer claim a mismatched slug breaks
routing, because it no longer does.

test_page_routing.py round-trips pages -> urlPath -> page(path:) through the
real schema against a drifted slug, and fails on the previous resolvers.
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

@kausal-code-coverage

kausal-code-coverage Bot commented Sep 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 83.78378% with 6 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/nodes/models.py 81.81% 0 Missing and 2 partials ⚠️
src/pages/page_interface.py 71.42% 1 Missing and 1 partial ⚠️
src/pages/url_paths.py 87.50% 1 Missing and 1 partial ⚠️

Impacted file tree graph

@@                         Coverage Diff                         @@
##           fix/repair-page-slugs-revisions     #286      +/-   ##
===================================================================
+ Coverage                            56.99%   57.02%   +0.03%     
===================================================================
  Files                                  357      358       +1     
  Lines                                52684    52707      +23     
  Branches                              8151     8159       +8     
===================================================================
+ Hits                                 30026    30056      +30     
+ Misses                               20338    20329       -9     
- Partials                              2320     2322       +2     
Flag Coverage Δ
e2e-tests 18.61% <35.13%> (+0.01%) ⬆️
unittests 55.63% <83.78%> (+0.06%) ⬆️

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

Files with missing lines Coverage Δ
src/pages/schema.py 91.17% <100.00%> (+2.77%) ⬆️
src/nodes/models.py 73.84% <81.81%> (+<0.01%) ⬆️
src/pages/page_interface.py 64.61% <71.42%> (-3.08%) ⬇️
src/pages/url_paths.py 87.50% <87.50%> (ø)

... and 2 files with indirect coverage changes

Impacted file tree graph

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

1 participant