Skip to content

Route applications by host/urlPath in the root config - #612

Open
kriszyp wants to merge 4 commits into
mainfrom
kris/root-config-app-mount-docs
Open

Route applications by host/urlPath in the root config#612
kriszyp wants to merge 4 commits into
mainfrom
kris/root-config-app-mount-docs

Conversation

@kriszyp

@kriszyp kriszyp commented Jul 27, 2026

Copy link
Copy Markdown
Member

Summary

Follow-up to Document middleware host and path routing (#595), which is already merged.

#595 documented host/urlPath as a component-config.yaml setting. That described the mechanism accurately but put the routing in the wrong place: where an application is served is a deployment concern, and a value checked into the application can't be remapped per environment (the env-config overlay is root-config-only). On a root-config application entry those keys were also silently inert.

Core now treats the application's root-config entry as authoritative — Route applications by host/urlPath declared in the root config (HarperFast/harper#1964) — so these docs lead with that placement.

Changes

  • reference/http/overview.md — mount an application from the root harper-config.yaml; a plugin's own urlPath positions it within the app and the mount is prefixed onto it; a root-config host overrides one the app shipped. Adds a "what a mount does not do" section: it is not a resource namespace, and it cannot constrain legacy Fastify routes by host.
  • reference/http/api.mdhost matching is case-insensitive, not case-sensitive as previously documented. Hostnames are case-insensitive (RFC 4343) and clients send them lowercased, so the old behavior made a configured API.example.com unmatchable; core fixed the compare. Also notes bare (unbracketed) IPv6 literals.
  • reference/operations-api/operations.md — documents host on deploy_component and the accepted forms for both it and urlPath.
  • 5.2 release notes — lead with the application mount.

Note

The HttpOptions case-sensitivity correction describes behavior that changes in harper#1964, so this shouldn't merge ahead of it.

npm run format:check and npm run build pass (one pre-existing broken anchor in the 5.1 release notes, unrelated).

Generated by Claude Opus 5.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the documentation for middleware routing, detailing application-level routing via the root harper-config.yaml or deploy-time parameters, and how it composes with plugin-level routing. It also clarifies host-matching behavior, such as case-insensitivity and IPv6 formatting. The review feedback recommends using a relative link instead of an absolute versioned link in the operations API documentation to prevent future version-pinning issues.

Comment thread reference/operations-api/operations.md Outdated
@github-actions
github-actions Bot temporarily deployed to pr-612 July 27, 2026 18:14 Inactive
@github-actions

Copy link
Copy Markdown

🚀 Preview Deployment

Your preview deployment is ready!

🔗 Preview URL: https://preview.harper-documentation.harperfabric.com/pr-612

This preview will update automatically when you push new commits.

1 similar comment
@github-actions

Copy link
Copy Markdown

🚀 Preview Deployment

Your preview deployment is ready!

🔗 Preview URL: https://preview.harper-documentation.harperfabric.com/pr-612

This preview will update automatically when you push new commits.

@github-actions
github-actions Bot temporarily deployed to pr-612 July 27, 2026 18:53 Inactive
@kriszyp
kriszyp requested a review from cb1kenobi July 27, 2026 19:07
@kriszyp
kriszyp marked this pull request as ready for review July 27, 2026 19:07
@kriszyp
kriszyp requested a review from a team as a code owner July 27, 2026 19:07
Comment thread reference/http/overview.md Outdated
@kriszyp

kriszyp commented Jul 28, 2026

Copy link
Copy Markdown
Member Author

Addressed @cb1kenobi's feedback on reference/http/overview.md in 89ec9b6 — confirmed against harper#1964 (kris/root-config-app-mount branch): fastifyRoutes.ts's handleApplication throws when a host-mounted app declares fastifyRoutes, and componentLoader.ts catches it via componentLifecycle.failed(...), so the component fails to load rather than continuing with a warning. Updated the doc to say Harper refuses to load it. Thread resolved.

— KrAIs (Claude Sonnet 5)

@github-actions

Copy link
Copy Markdown

🚀 Preview Deployment

Your preview deployment is ready!

🔗 Preview URL: https://preview.harper-documentation.harperfabric.com/pr-612

This preview will update automatically when you push new commits.

@github-actions
github-actions Bot temporarily deployed to pr-612 July 28, 2026 12:54 Inactive

@Ethan-Arrowood Ethan-Arrowood left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cross-checked against harper#1964. The substance is accurate — mount-strip semantics, per-environment remounting, the harper deploy … host= urlPath= example, the payload-deploy rejection note, bare-IPv6 forms in all three files, and the resource-registry caveat all verified, and correcting the previously-documented case-sensitive host matching is a good catch.

Two things before merge, one of them a hold.

Hold behind #1964. I reviewed that PR earlier today and raised two findings that bear directly on this text: host-mounted apps currently don't match under HTTP/2 (matchesRoute never reads :authority), and a hand-edited root-config host is never validated. If the h2 gap gets fixed in core, this doc needs no change; if h1-only is accepted as a design limitation, these docs must say so. Worth re-reading the two host-matching sentences (api.md:51, overview.md:77) once #1964 settles.

Minor: link style is inconsistent between two of the touched files — operations.md:609 uses ../http/overview.md#middleware-routing while plugin-api.md:47 uses extensionless ../http/overview#middleware-routing. Build passes either way; extensionless matches the surrounding files.

sent with Claude Opus 5


- **It does not namespace resources.** Exported tables live in one instance-wide registry, so a table exported by one application is reachable through any mounted REST route, not only its own.
- **It does not constrain legacy Fastify routes by host.** `fastifyRoutes` registers as a global fallback outside the routed middleware chain, so those routes answer on every hostname. A `urlPath` mount does apply (it becomes the Fastify route prefix); a `host` mount does not, and Harper refuses to load a host-mounted application that declares `fastifyRoutes` rather than silently serving it unconstrained. Port them to `server.http()` for host routing.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This overstates the failure scope. fastifyRoutes.ts does throw in #1964, but the loader's catch is per plugin inside the app's config loop (componentLoader.ts#L737) — it marks the fastifyRoutes component failed and continues; the code comment says as much ("contained to this component by the loader's per-component try/catch, so it does not take down the rest of the application"). So the app's other handlers (rest, static, …) still load and serve on the host mount; only the legacy routes fail.

As written, a reader expects the whole app to refuse to start and would misdiagnose a partially-running app — the same class of mismatch @cb1kenobi already caught once in the opposite direction (docs said "warns", code throws). Suggested wording: "Harper fails the application's fastifyRoutes with a load error rather than silently serving them unconstrained; the application's other handlers still load."

kriszyp and others added 4 commits July 29, 2026 12:21
Follow-up to #595. That PR documented `host`/`urlPath` as a component-`config.yaml`
setting, which described the mechanism but put the routing in the wrong place: where an
application is served is a deployment concern, and a value checked into the application
cannot be remapped per environment (the env-config overlay is root-config-only).

Harper now treats the application's root-config entry as authoritative (HarperFast/harper
PR pending), so lead with that placement:

- `reference/http/overview.md` — mount an application from the root `harper-config.yaml`;
  a plugin's own `urlPath` positions it within the app and the mount is prefixed onto it,
  while a root-config `host` overrides one the app shipped.
- `reference/components/plugin-api.md` — scope the plugin-level options to "within the
  application" and point at the root-config mount.
- `reference/operations-api/operations.md` — document `host` on `deploy_component` and
  note that both it and `urlPath` are persisted to the root-config entry.
- 5.2 release notes — lead with the application mount.
Follows the cross-model review of the core change:

- A mount is a routing prefix, not an isolation boundary. Exported tables are instance-wide, so
  a table exported by one application is reachable through any mounted REST route.
- Legacy `fastifyRoutes` register as a global fallback outside the routed chain, so a `host`
  mount cannot constrain them (a `urlPath` mount does apply). Harper warns in that case.
- Host matching is case-insensitive, not case-sensitive as `HttpOptions` previously documented —
  hostnames are case-insensitive (RFC 4343) and clients send them lowercased, so the old
  behavior made a configured `API.example.com` unmatchable.
- IPv6 hosts are configured as a bare literal, not bracketed; `urlPath` rejects `.` segments.
Addresses PR review:

- `deployComponentValidator` declares `.with('urlPath','package').with('host','package')`, so
  both are rejected on a payload-only deploy. The "Additional parameters" list implied
  otherwise; state the requirement and point payload deploys at the root-config entry.
- Badge the new `host` parameter with v5.2.0 per the versioning rule.
- Use a relative link for the middleware-routing reference, matching the rest of the file
  (21 relative links vs the one absolute one this PR introduced).
harper#1964's handleApplication throws when a host-mounted application
declares fastifyRoutes, and componentLoader.ts catches it and marks the
component failed — it doesn't continue running with a warning logged.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

🚀 Preview Deployment

Your preview deployment is ready!

🔗 Preview URL: https://preview.harper-documentation.harperfabric.com/pr-612

This preview will update automatically when you push new commits.

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.

4 participants