Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions cmd/server_foreground.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ import (
"github.com/GoogleCloudPlatform/scion/pkg/store/entadapter"
"github.com/GoogleCloudPlatform/scion/pkg/util"
"github.com/GoogleCloudPlatform/scion/pkg/util/logging"
"github.com/GoogleCloudPlatform/scion/web"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -328,6 +329,10 @@ func runServerStart(cmd *cobra.Command, args []string) error {
hubSrv.StartBackgroundServices(ctx)
}

if !web.AssetsEmbedded && webAssetsDir == "" {
log.Printf("WARNING: This binary was built without web assets. The web UI will not be available.")
log.Printf("Run 'make web' and rebuild to include the web frontend, or use --web-assets-dir.")

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.

medium

The application is configured to use structured logging via slog (which supports GCP logging format, OTel, etc.). Using standard log.Printf bypasses the structured logging handler, meaning these warnings won't be correctly formatted as structured JSON logs in production/hosted environments. Consider using slog.Warn instead to ensure the warning is properly captured by the configured logging pipeline.

Suggested change
log.Printf("WARNING: This binary was built without web assets. The web UI will not be available.")
log.Printf("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 web' and rebuild to include the web frontend, or use --web-assets-dir.")

}
log.Printf("Starting Web Frontend on %s:%d", cfg.Hub.Host, webPort)
wg.Add(1)
go func() {
Expand Down
5 changes: 4 additions & 1 deletion pkg/hub/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,10 @@

func (ws *WebServer) serveStaticAsset(w http.ResponseWriter, r *http.Request) {
if ws.assetsDisk == "" && ws.assets == nil {
http.Error(w, "no assets available", http.StatusNotFound)
w.Header().Set("Content-Type", "text/html; charset=utf-8")
w.Header().Set("Cache-Control", "no-cache")
w.WriteHeader(http.StatusNotFound)
fmt.Fprint(w, noAssetsPage)

Check failure on line 771 in pkg/hub/web.go

View workflow job for this annotation

GitHub Actions / golangci-lint

Error return value of `fmt.Fprint` is not checked (errcheck)
return
}

Expand Down
Loading