Skip to content

static plugin: setting urlPath prevents all files from being served (5.1.15) #1583

Closed

Description

@kylebernhardy

Bug Summary

Configuring the built-in static plugin with the documented urlPath option results in no files being served at all — every candidate URL returns 404. Removing urlPath (same files, same glob) serves correctly.

Steps to Reproduce

Minimal component (two files):

static-min/
├── config.yaml
└── web/
    └── test.css

config.yaml:

static:
  files: 'web/**'
  urlPath: 'assets'
  1. harper dev .
  2. curl -i http://localhost:9926/assets/test.css → 404
  3. Also 404: /test.css, /assets/web/test.css, /web/test.css (no candidate path serves)

Control cases on the same instance:

  • config.yaml with only static: { files: 'web/**' } → GET /test.css → 200 ✅
  • No config.yaml at all (default config) → GET /test.css → 200 ✅

So the regression is isolated to the presence of urlPath.

Expected Behavior

Per the Static Files docs (files and urlPath section): with urlPath: 'assets', GET /assets/test.css should return web/test.css.

Actual Behavior

404 for every path; no error or warning in the log (level warn). At debug level the only nearby output is Initial scan complete, still waiting for N pending file reads. Files added to web/ after startup are also never served, so the plugin's file map appears to stay empty (or is keyed differently than the request handler's staticFiles.get(req.pathname) lookup in server/static.ts expects). resolveBaseURLPath('…', 'assets') → /assets/ and deriveURLPath → /assets/test.css look correct in isolation, so the suspect is the entry pipeline when urlPath is set rather than the URL derivation itself.

Environment

  • Harper 5.1.15 (npm global install)
  • Node v24.16.0, macOS (darwin 25.5.0, arm64)
  • Reproduced under both harper dev and a fresh install's harper start

Workaround

Nest the files so the glob-base strip produces the prefix instead: move files to web/assets/… and use static: { files: 'web/**' } with no urlPath — files then serve at /assets/….

Context

Found while dogfooding the docs-site replatform (serving docs.harperdb.io from Harper).

Activity

  1. self-assigned this
    on Jul 3, 2026
  2. kriszyp commented on Jul 6, 2026

    @kriszyp
    Member

    Root cause from exploratory QA (harper 228eacc0f) — confirmed total serve-outage + traced:

    Setting urlPath on the static plugin makes every path 404 (remapped prefix, no-slash, old default paths, root — wrong-prefix ruled out; /assets/ neither serves index nor redirects). Control (files:'web/**', no urlPath) serves all files → plugin is fine.

    Mechanism: buildRoutedChain (server/middlewareChain.ts) strips the matched urlPath prefix from req.pathname before the static handler (/assets/style.css → /style.css), but server/static.ts's EntryHandler keys its staticFiles/indexEntries maps by the full baseURLPath including urlPath (/assets/style.css). The stripped lookup key never matches the prefixed map key → every request misses.

    Repro: local qa-scratch/qa450-static-urlpath.test.ts.

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

Metadata

Metadata

Assignees

Labels

area:componentsComponents / applications subsystembugSomething isn't working

Type

No type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions