feat(api): organizations with own status page servers serve their pages alone
ci / lint (push) Skipped
ci / test (push) Skipped
ci / build (push) Skipped
ci / image (push) Skipped
ci / lint (pull_request) Canceled after 6m3s
ci / test (pull_request) Canceled after 6m2s
ci / build (pull_request) Canceled after 0s
ci / image (pull_request) Canceled after 0s

The platform's status page servers handed out every published page,
including those of organizations running their own servers. Once one of
an organization's own status page servers has connected, the agent API
now answers the platform's servers 404 for its pages, so they drop them
from their cache, and only the organization's servers serve them. A
created but never connected token changes nothing, so moving over does
not take the pages offline.

The console no longer links such pages to the platform's address,
which would not serve them; the editor says who does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
This commit is contained in:
Sebastian UnterschützandClaude Opus 5.5 committed 2026-11-24 22:45:37 +01:00
1 parent 20874a5a87
commit c0239e15bb
11 files changed
+905 -778

No files matched your search

+22 -6
View File
@@ -1016,19 +1016,31 @@ func (s *Server) channelsView(c *gin.Context, p *principal, page web.Page, me we
return web.ChannelsPage(page, me, v), nil
}
func (s *Server) pageURL(p store.StatusPage) string {
// pageURL is where p is reachable, or empty when only the organization's
// own status page servers serve it, at an address the platform does not
// know.
func (s *Server) pageURL(p store.StatusPage, ownServers bool) string {
if p.CustomDomain != nil && p.DomainVerifiedAt != nil {
return "https://" + *p.CustomDomain + "/"
}
if ownServers {
return ""
}
return strings.TrimSuffix(s.cfg.StatusPageURL, "/") + "/" + p.Slug
}
func (s *Server) statusPagesView(c *gin.Context, p *principal, page web.Page, me web.Me) (templ.Component, error) {
ctx := c.Request.Context()
var rows []store.StatusPage
var (
rows []store.StatusPage
own bool
)
err := s.db.Tx(ctx, p.scope(), func(q *store.Queries) error {
var err error
rows, err = q.ListStatusPages(ctx)
if rows, err = q.ListStatusPages(ctx); err != nil {
return err
}
own, err = q.OrgServesOwnPages(ctx, &p.Org.ID)
return err
})
if err != nil {
@@ -1041,7 +1053,7 @@ func (s *Server) statusPagesView(c *gin.Context, p *principal, page web.Page, me
}
v.Pages = append(v.Pages, web.PageRow{
ID: r.ID.String(), Title: r.Title, Slug: r.Slug, Published: r.Published,
URL: s.pageURL(r), Domain: deref(r.CustomDomain), Suspended: r.SuspendedAt != nil,
URL: s.pageURL(r, own), Domain: deref(r.CustomDomain), Suspended: r.SuspendedAt != nil,
})
}
return web.StatusPagesPage(page, me, v), nil
@@ -1059,6 +1071,7 @@ func (s *Server) statusPageEditor(c *gin.Context, p *principal, page web.Page, m
pageGroups []store.StatusPageGroup
orgGroups []store.MonitorGroup
monitors []store.Monitor
own bool
)
err = s.db.Tx(ctx, p.scope(), func(q *store.Queries) error {
var err error
@@ -1074,7 +1087,10 @@ func (s *Server) statusPageEditor(c *gin.Context, p *principal, page web.Page, m
if orgGroups, err = q.ListGroups(ctx); err != nil {
return err
}
monitors, err = q.ListMonitors(ctx)
if monitors, err = q.ListMonitors(ctx); err != nil {
return err
}
own, err = q.OrgServesOwnPages(ctx, &p.Org.ID)
return err
})
if errors.Is(err, pgx.ErrNoRows) {
@@ -1089,7 +1105,7 @@ func (s *Server) statusPageEditor(c *gin.Context, p *principal, page web.Page, m
Published: row.Published, ShowDetails: row.ShowComponentDetails,
Suspended: row.SuspendedAt != nil, SuspendedReason: row.SuspendedReason,
Accent: v.Theme.Accent, LogoURL: v.Theme.LogoURL, CSS: v.Theme.CSS,
URL: s.pageURL(row), Domain: deref(row.CustomDomain), DomainVerified: v.DomainVerified,
URL: s.pageURL(row, own), OwnServers: own, Domain: deref(row.CustomDomain), DomainVerified: v.DomainVerified,
HasOrgGroups: len(orgGroups) > 0,
}
if v.DomainRecord != nil {
+12 -4
View File
@@ -346,14 +346,22 @@ func (s *Server) agentPage(c *gin.Context) {
fail(c, http.StatusBadRequest, "invalid_input")
return
}
var page store.StatusPage
var (
page store.StatusPage
own bool
)
a := agentOf(c)
err := s.db.Tx(ctx, tenant.System(), func(q *store.Queries) error {
var err error
page, err = q.FindPublishedPage(ctx, store.FindPublishedPageParams{Host: host, Slug: slug})
if page, err = q.FindPublishedPage(ctx, store.FindPublishedPageParams{Host: host, Slug: slug}); err != nil || a.OrgID != nil {
return err
}
own, err = q.OrgServesOwnPages(ctx, &page.OrgID)
return err
})
a := agentOf(c)
if errors.Is(err, pgx.ErrNoRows) || (err == nil && a.OrgID != nil && *a.OrgID != page.OrgID) {
// The platform's servers leave the pages of organizations that serve
// them on their own servers to those.
if errors.Is(err, pgx.ErrNoRows) || (err == nil && (own || a.OrgID != nil && *a.OrgID != page.OrgID)) {
fail(c, http.StatusNotFound, "not_found")
return
}
+20
View File
@@ -192,6 +192,26 @@ func TestStatusPages(t *testing.T) {
st, body = editor.do("PUT", "/api/v1/org/statuspages/"+second, map[string]any{"slug": "x-second", "title": "x"})
expect(t, "edit page out of scope", st, body, http.StatusNotFound, "not_found")
})
t.Run("own servers replace the platform's", func(t *testing.T) {
org := uuid.MustParse(owner.orgID())
own := e.statuspageClient(t, &org)
if _, err := platform.Page(context.Background(), "", slug); err != nil {
t.Fatalf("platform server before the own one connected: %v", err)
}
if _, err := own.Hello(context.Background()); err != nil {
t.Fatal(err)
}
if _, err := platform.Page(context.Background(), "", slug); !errors.Is(err, agentapi.ErrNotFound) {
t.Errorf("platform server still gets the page: %v", err)
}
if snap, err := own.Page(context.Background(), "", slug); err != nil || snap.Title != "Acme Status" {
t.Errorf("own server Page() = %v, %v", snap.Title, err)
}
if _, _, html := owner.page("/statuspages/" + pageID); !strings.Contains(html, "own status page servers serve its pages") {
t.Error("the editor does not say who serves the pages")
}
})
}
func editorEmail(b *browser) string {