fix(amazonq): serve webview assets without Jetty PathResource (#560)#562
Draft
laileni-aws wants to merge 1 commit into
Draft
fix(amazonq): serve webview assets without Jetty PathResource (#560)#562laileni-aws wants to merge 1 commit into
laileni-aws wants to merge 1 commit into
Conversation
Eclipse 2026-06 (4.40.0) bundles a newer Jetty whose PathResource#resolve builds a URI-style path such as "/C:/Users/.../amazonq-ui.js" and passes it to Path#resolve, which throws InvalidPathException on Windows (illegal ':' after the leading slash). This left the Amazon Q chat and login webviews showing a blank screen. Replace the ResourceHandler/PathResource-based asset serving with a small java.nio-based handler that resolves the requested path relative to the asset directory, which stays valid on every platform. The handler keeps a path-traversal guard and advertises content types by extension. The public API of WebviewAssetServer is unchanged, so callers are unaffected. Adds WebviewAssetServerTest covering content-type resolution and HTTP serving (asset retrieval, nested assets, and 404 handling).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Closes #560.
On Eclipse 2026-06 (4.40.0) the Amazon Q chat (and login) view renders as a blank screen. The webview asset server throws:
Root cause
WebviewAssetServerserved the LSP-provided UI directory through Jetty'sResourceHandler+setBaseResource(<dir>). To serve a request such asGET /amazonq-ui.js, Jetty resolves the request path against the base resource viaPathResource#resolve.The Jetty version the plugin builds against (12.0.9, Eclipse 2024-06) implemented this with
Paths.get(resolvedUri), which correctly handles a Windowsfile:///C:/...URI. The newer Jetty bundled with Eclipse 4.40.0 changedPathResource#resolveto delegate toresolveSchemeSpecificPath(...), which combines the request into a URI-style string (/C:/Users/.../amazonq-ui.js) and passes it toPath#resolve(String). On Windows that string is rejected —:is illegal at index 2 because of the leading/before the drive letter — so no asset is ever served and the webview stays blank.Because the broken code lives in the Jetty bundle supplied by the Eclipse target platform, we can't fix it there; the plugin must stop relying on
PathResource#resolve.Fix
Replace the
ResourceHandlerwith a smallHandler.Abstract(StaticFileHandler) that serves files from the asset directory usingjava.nio:baseDir.resolve(relativePath)), so the resulting path never contains a leading-slash + drive-letter sequence and stays valid on every platform;resolved.startsWith(baseDir));text/javascript,text/css, …).The public API of
WebviewAssetServer(resolve,getUri,stop), theContextHandler, context path/, and the127.0.0.1virtual-host restriction are all unchanged, soChatWebViewAssetProviderandToolkitLoginWebViewAssetProviderneed no changes.org.eclipse.jetty.http(already a transitive dependency oforg.eclipse.jetty.server) is added toRequire-BundleforHttpHeader/HttpStatus.Testing
Added
WebviewAssetServerTest(JUnit 5):getContentTyperesolution (known extensions, case-insensitivity, unknown / missing extension fallback);404for a missing asset.Verified locally against the real Jetty 12.0.9 API (the version the plugin builds against):
javac -Xlint:allcompiles cleanly;plugin/checkstyle.xml) reports no violations.