carlos / platform Public

console: instance list q also matches the host each row shows

Astra final review P2-5. The API filtered q against rec.Host only, so a
search for the name URL the CLI table prints found nothing. q now also
matches the row's public_host, from the request's one canonical view,
as the page filter does.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev f5efc874d999a28afb49f8e12610548cad8fc99d parent d064559
2 files changed, +44 −2
  • internal/console/apiinstances.go +6 −2
  • internal/console/instancelist_publichost_test.go +38 −0
diff --git a/internal/console/apiinstances.go b/internal/console/apiinstances.go
index 13aa3af81..3dc2c7de0 100644
--- a/internal/console/apiinstances.go
+++ b/internal/console/apiinstances.go
@@ -1322,7 +1322,11 @@ func (s *Server) handleAPIInstanceList(w http.ResponseWriter, r *http.Request) {
for _, rec := range recs {
h := health[rec.Host]
counts[h]++
- if q.Q != "" && !strings.Contains(rec.Host, q.Q) {
+ // q matches the host the list shows as well as the identity host,
+ // as the page's filter does: a search for the name URL a row
+ // prints finds that row.
+ public := recordPublicHost(canon, rec)
+ if q.Q != "" && !strings.Contains(rec.Host, q.Q) && (public == "" || !strings.Contains(public, q.Q)) {
continue
}
if q.Channel != "" && rec.Channel != q.Channel {
@@ -1333,7 +1337,7 @@ func (s *Server) handleAPIInstanceList(w http.ResponseWriter, r *http.Request) {
}
ro := join.rollout(rec.Host, acct.Sqid, app)
refusal, refusalsCapped := join.refusalFor(rec, ro)
- matched = append(matched, instanceListRecord{Record: rec, PublicHost: recordPublicHost(canon, rec),
+ matched = append(matched, instanceListRecord{Record: rec, PublicHost: public,
ConfigRefusal: refusal, RefusalsCapped: refusalsCapped,
StagedVersion: join.versions[rec.Host], Health: h, Upstreams: join.upstreams[rec.Host],
ServedBy: served[rec.Host], Gated: rec.Gate != "", DBBytes: join.dbSize(rec.Host),
diff --git a/internal/console/instancelist_publichost_test.go b/internal/console/instancelist_publichost_test.go
new file mode 100644
index 000000000..1a46f592c
--- /dev/null
+++ b/internal/console/instancelist_publichost_test.go
@@ -0,0 +1,38 @@
+package console
+
+// Account subdomains, final review fix (Astra P2-5): the instance list's q
+// matches the host each row shows. Neutral names: bab (the ops account),
+// the name harbour, the apps domain oncarlos.com.
+
+import (
+ "encoding/json"
+ "net/http"
+ "net/url"
+ "testing"
+)
+
+// TestInstanceListQueryMatchesPublicHost: the instance list's q finds an
+// instance by the name host it shows (public_host) as well as by its own.
+func TestInstanceListQueryMatchesPublicHost(t *testing.T) {
+ fx, member, _ := nsShopFixture(t, "code-canon-q")
+ enableInstances(t, fx, "shop", nsShopManifest("shop.bab."+nsApps))
+ nsHold(t, fx, "harbour", fx.sqid)
+ host := "c1.shop.bab." + nsApps
+ if code, _, out := rawReq(t, http.MethodPost, instancesURL(fx, "bab", "shop"), member, `{"host":"`+host+`","region":"ie"}`); code != http.StatusCreated {
+ t.Fatalf("create = %d %s", code, out)
+ }
+ for q, want := range map[string]int{"c1.shop.harbour": 1, "c1.shop.bab": 1, "harbour." + nsApps: 1, "c9.shop": 0} {
+ code, _, out := rawReq(t, http.MethodGet, instancesURL(fx, "bab", "shop")+"?q="+url.QueryEscape(q), member, "")
+ var list struct {
+ Instances []struct {
+ Host string `json:"host"`
+ } `json:"instances"`
+ }
+ if err := json.Unmarshal([]byte(out), &list); code != http.StatusOK || err != nil {
+ t.Fatalf("list q=%s = %d %s", q, code, out)
+ }
+ if len(list.Instances) != want {
+ t.Errorf("list q=%s = %d instance(s), want %d: %s", q, len(list.Instances), want, out)
+ }
+ }
+}