Skip to content

fix(web): detect incomplete embedded assets and serve error page#323

Closed
ptone wants to merge 2 commits into
mainfrom
scion/missing-web-assets-error
Closed

fix(web): detect incomplete embedded assets and serve error page#323
ptone wants to merge 2 commits into
mainfrom
scion/missing-web-assets-error

Conversation

@ptone

@ptone ptone commented Jun 28, 2026

Copy link
Copy Markdown
Owner

Summary

  • When built without make web, the embedded dist/client directory exists but only has .gitkeep. Previously this caused a blank page because AssetsEmbedded was true and the sub-FS was non-nil, so the SPA shell referenced main.js which 404'd silently.
  • Now NewWebServer validates that assets/main.js exists in the embedded FS. If missing, ws.assets is left nil so the existing noAssetsPage fallback renders, explaining how to rebuild with assets.
  • Updated the error page message to recommend make all (or make web && make build).
  • Added startup warning in server_foreground.go for the incomplete-assets case.

Test plan

  • go build ./... compiles successfully
  • All existing web tests pass (SPA shell, no-assets error page, healthz, API)
  • Tests updated: error page assertion matches new message text; test helpers provide stub FS when embedded assets are incomplete

When the binary is built without running 'make web' first, the embedded
dist/client directory exists but only contains .gitkeep. Previously this
caused a blank page because AssetsEmbedded was true and the sub-FS was
non-nil, so the SPA shell referenced main.js which 404'd silently.

Now NewWebServer validates that assets/main.js exists in the embedded FS
after creating it. If missing, ws.assets is left nil so the existing
noAssetsPage fallback kicks in, explaining how to rebuild with assets.

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request improves the detection of incomplete embedded web assets by checking for the presence of 'assets/main.js' within the embedded filesystem, updating warning messages, and updating tests to mock this file. Feedback on the changes suggests removing a redundant filesystem check and duplicate warning log in 'cmd/server_foreground.go', as these checks are already performed inside 'NewWebServer'.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread cmd/server_foreground.go
Comment on lines 333 to 341
if !web.AssetsEmbedded && webAssetsDir == "" {
slog.Warn("This binary was built without web assets. The web UI will not be available. Run 'make web' and rebuild to include the web frontend, or use --web-assets-dir.")
slog.Warn("This binary was built without web assets. The web UI will not be available. Run 'make all' (or 'make web && make build') to rebuild with web assets included, or use --web-assets-dir.")
} else if web.AssetsEmbedded && webAssetsDir == "" {
if sub, err := fs.Sub(web.ClientAssets, "dist/client"); err == nil {
if _, err := fs.Stat(sub, "assets/main.js"); err != nil {
slog.Warn("Embedded web assets are incomplete (main.js missing). The web UI will not be available. Run 'make all' (or 'make web && make build') to rebuild with web assets included, or use --web-assets-dir.")
}
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

This block introduces redundant file system checks and duplicate warning logs.

When enableWeb is true, initWebServer is called on line 326, which instantiates the web server via NewWebServer. Inside NewWebServer (in pkg/hub/web.go), the exact same checks (fs.Sub and fs.Stat for assets/main.js) are already performed, and appropriate warnings/errors are logged.

Therefore, executing these checks and logging another warning here is redundant and leads to duplicate warning messages in the console at startup. We can safely remove this entire block.

Note: Removing this block will make the "io/fs" import unused, so it should be removed from the import block as well.

When fs.Sub fails to create a sub-filesystem from embedded web assets,
the error message now includes actionable rebuild instructions
(run make web && make build) so users know how to resolve the issue.
@ptone ptone closed this Jun 28, 2026
@ptone ptone deleted the scion/missing-web-assets-error branch June 28, 2026 12:11
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.

1 participant