Skip to content

fix: add trailing slash to hardcoded kubeflow BASE_PATH in webpack config - #1349

Open
christian-heusel wants to merge 1 commit into
kubeflow:notebooks-v2from
christian-heusel:fix/webpack-publicpath-trailing-slash
Open

fix: add trailing slash to hardcoded kubeflow BASE_PATH in webpack config#1349
christian-heusel wants to merge 1 commit into
kubeflow:notebooks-v2from
christian-heusel:fix/webpack-publicpath-trailing-slash

Conversation

@christian-heusel

Copy link
Copy Markdown
Member

Summary

In production/Kubeflow-mode builds of workspaces/frontend, opening a route that requires a lazily-loaded webpack chunk (e.g. the Workspace details view) fails with a ChunkLoadError. The browser requests a malformed URL like /workspaces449.bundle.js instead of /workspaces/449.bundle.js, which doesn't match this frontend's Istio VirtualService prefix match (prefix: /workspaces/) and therefore never reaches the app's own nginx.

Root cause: config/webpack.common.js and config/webpack.dev.js hardcode BASE_PATH to the literal '/workspaces' (no trailing slash) whenever DEPLOYMENT_MODE === 'kubeflow':

const BASE_PATH = DEPLOYMENT_MODE === 'kubeflow' ? '/workspaces' : PUBLIC_PATH;

This value becomes webpack's runtime publicPath (__webpack_require__.p), which webpack's dynamic import() runtime uses via raw string concatenation with the chunk filename — it does not insert a / separator, since publicPath is expected to already end in one. So a chunk file 449.bundle.js gets requested as '/workspaces' + '449.bundle.js' = /workspaces449.bundle.js.

The entry bundle (app.bundle.js) is unaffected because html-webpack-plugin normalizes publicPath itself when injecting the <script> tag and <base href> into index.html — only dynamically imported chunks go through the raw webpack runtime and hit the bug. This is also why it's easy to miss in local dev: .env.tilt sets DEPLOYMENT_MODE=standalone and PUBLIC_PATH=/workspaces/ (with a trailing slash already), which takes the other branch of the ternary and never triggers the bug.

Fix

Add the missing trailing slash to the hardcoded kubeflow-mode literal in both files, matching what PUBLIC_PATH=/workspaces/ already does correctly for the non-kubeflow branch:

- const BASE_PATH = DEPLOYMENT_MODE === 'kubeflow' ? '/workspaces' : PUBLIC_PATH;
+ const BASE_PATH = DEPLOYMENT_MODE === 'kubeflow' ? '/workspaces/' : PUBLIC_PATH;

Verification

  • Ran npm run build:prod and confirmed the built app.bundle.js now embeds __webpack_require__.p="/workspaces/" (previously "/workspaces"), so lazily-loaded chunks now resolve to /workspaces/<id>.bundle.js.
  • Confirmed dist/index.html's <base href> and <script src> are unaffected (still correctly /workspaces/...) — only the runtime chunk-loading path was wrong before this change.
  • npm run test:lint passes.
  • Reproduced the original bug against a live Kubeflow Community distribution deployment (KIND cluster) before the fix: opening a Workspace's details panel threw ChunkLoadError: Loading chunk 449 failed. (missing: http://<host>/workspaces449.bundle.js) in the browser console, with the network request returning a non-2xx response since it doesn't match this service's Istio route.

Test plan

  • npm run build:prod succeeds and the emitted app.bundle.js has publicPath = /workspaces/
  • npm run test:lint passes
  • Deploy to a cluster running the Kubeflow Community distribution manifests, open Notebooks v2 → Workspaces → click into a workspace's details panel, confirm no ChunkLoadError and the details panel renders (reviewer/CI verification)

…nfig

In config/webpack.common.js and config/webpack.dev.js, BASE_PATH for
DEPLOYMENT_MODE=kubeflow was hardcoded to '/workspaces' without a
trailing slash. This value is baked into the production build as
webpack's runtime publicPath (__webpack_require__.p), and webpack's
dynamic-chunk-loading runtime concatenates that value directly with
the chunk filename without inserting a separator. As a result, any
lazily-loaded route chunk was requested as e.g.
"/workspaces449.bundle.js" instead of "/workspaces/449.bundle.js" in
production, which the Istio VirtualService for this frontend
(prefix: /workspaces/) never matches, causing a ChunkLoadError in the
browser when e.g. opening the Workspace details view.

The entry bundle itself was unaffected because html-webpack-plugin
normalizes publicPath when injecting <script>/<base> tags into
index.html, masking the bug for anything not code-split.

Assisted-by: Claude Sonnet 5 <noreply@anthropic.com>
Signed-off-by: Christian Heusel <christian@heusel.eu>
@github-project-automation github-project-automation Bot moved this to Needs Triage in Kubeflow Notebooks Aug 24, 2026
@google-oss-prow google-oss-prow Bot added the area/frontend area - related to frontend components label Aug 24, 2026
@google-oss-prow

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign paulovmr for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@google-oss-prow google-oss-prow Bot added area/v2 area - version - kubeflow notebooks v2 size/XS labels Aug 24, 2026

@thisis-Shitanshu thisis-Shitanshu left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Tested this against a local KIND Kubeflow Community Distribution deployment.

I was able to reproduce the issue before the change: opening the Workspace details view requested lazy chunks such as /workspaces6990.bundle.js, which returned HTML in my environment and resulted in Unexpected token '<' followed by a ChunkLoadError.

Image Image

I then built and deployed this PR and repeated the same flow with cache disabled. The chunk is now requested correctly as /workspaces/6990.bundle.js, returns application/javascript with 200, and the ChunkLoadError is gone.

Image Image

The trailing slash change looks correct to me. LGTM 👍

@google-oss-prow

Copy link
Copy Markdown

@thisis-Shitanshu: changing LGTM is restricted to collaborators

Details

In response to this:

Tested this against a local KIND Kubeflow Community Distribution deployment.

I was able to reproduce the issue before the change: opening the Workspace details view requested lazy chunks such as /workspaces6990.bundle.js, which returned HTML in my environment and resulted in Unexpected token '<' followed by a ChunkLoadError.

Image Image

I then built and deployed this PR and repeated the same flow with cache disabled. The chunk is now requested correctly as /workspaces/6990.bundle.js, returns application/javascript with 200, and the ChunkLoadError is gone.

Image Image

The trailing slash change looks correct to me. LGTM 👍

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@christian-heusel christian-heusel added this to the v2.0.0-beta.1 milestone Aug 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/frontend area - related to frontend components area/v2 area - version - kubeflow notebooks v2 size/XS

Projects

Status: Needs Triage

Development

Successfully merging this pull request may close these issues.

2 participants