Skip to content

[BUG] Pages: inferred path is wrong when a page module name contains the pages folder name #4168

Open

Description

@thejesh23

Describe your context

Current dev (dash 4.5.1), Python 3.14. Server side only, any browser or OS.

Describe the bug

When register_page(__name__) is called without path, _infer_path (dash/_pages.py:71) splits the module name on the pages folder name as a substring and keeps what follows the last match. A page module whose name contains the folder name loses part of its path:

pages folder "pages":  pages/landing_pages.py  -> path "/"        (expected "/landing-pages")
                       pages/homepages.py      -> path "/"        (expected "/homepages")
                       pages/subpages/report.py -> path "/report" (expected "/subpages/report")
pages folder "views":  views/overviews.py      -> path "/"        (expected "/overviews")

One such page silently takes over / and its real URL 404s. Two of them collide on /, and the first request to the app raises modules ['pages.homepages', 'pages.landing_pages'] have duplicate paths.

Expected behavior

The folder name should only match as a whole dotted part of the module name, so these pages get /landing-pages, /homepages, /subpages/report and /overviews.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions