High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.
fix: validate unknown browser names before running-browser conflict check
Bosch2897f1ba6476
diff --git a/internal/handlers/handler_browser.go b/internal/handlers/handler_browser.goindex a53931a5..8265bbc7 100644--- a/internal/handlers/handler_browser.go+++ b/internal/handlers/handler_browser.go@@ -23,6 +23,14 @@ func (h *Handlers) rejectBrowserConflictWithRunning(w http.ResponseWriter, requeif explicit == "" || h.Bridge == nil {return false}+ // Unknown names must fail validation (400) before the conflict check:+ // NormalizeBrowser coerces unknowns to chrome, so comparing them against+ // the running browser would emit a 409 advising a restart with a browser+ // that doesn't exist.+ if _, err := config.ParseBrowser(explicit, h.Config.BrowsersAvailable); err != nil {+ httpx.Error(w, http.StatusBadRequest, err)+ return true+ }running, ok := h.Bridge.RunningBrowser()if !ok || running == "" {return falsediff --git a/internal/handlers/navigation_browser_test.go b/internal/handlers/navigation_browser_test.goindex dec4ef21..6e5362b2 100644--- a/internal/handlers/navigation_browser_test.go+++ b/internal/handlers/navigation_browser_test.go@@ -566,6 +566,28 @@ func TestHandleNavigate_ExplicitBrowserConflictsWithRunning_409(t *testing.T) {}}+// An unknown browser name must fail validation (400) even when a different+// browser is running — a 409 advising "restart with --browser nonexistent"+// points the caller at a browser that doesn't exist.+func TestHandleNavigate_UnknownBrowserWithRunningBrowser_400Not409(t *testing.T) {+ m := &mockBridge{runningBrowser: config.BrowserGhostChrome}+ h := New(m, &config.RuntimeConfig{+ BrowsersAvailable: []string{config.BrowserGhostChrome},+ }, nil, nil, nil)++ body := []byte(`{"url":"http://localhost:3000","browser":"nonexistent_xyz"}`)+ req := httptest.NewRequest("POST", "/navigate", bytes.NewReader(body))+ w := httptest.NewRecorder()+ h.HandleNavigate(w, req)++ if w.Code != http.StatusBadRequest {+ t.Fatalf("unknown browser should 400 before the running-browser conflict check, got %d body=%s", w.Code, w.Body.String())+ }+ if !strings.Contains(w.Body.String(), "unknown browser") {+ t.Fatalf("400 payload should name the unknown browser error: %s", w.Body.String())+ }+}+func TestHandleNavigate_ImplicitBrowserIgnoresRunningMismatch(t *testing.T) {// Default chrome resolution against a running cloak server must not 409 —// only explicit intent conflicts.