carlos / platform Public

console: keep the pointing sentence beside a lone proof record

With no edge addresses known, a pending claim's only record is its proof,
and the page dropped the pointing sentence because the list was not
empty. The sentence now shows whenever no pointing record is listed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 36ddc44e5aa06e5b7094ddcdcc3ed5dfd0066762 parent d5cf865
2 files changed, +59 −3
  • internal/console/accountdomainspage.go +19 −3
  • internal/console/accountdomainspage_test.go +40 −0

CI failed — run details

diff --git a/internal/console/accountdomainspage.go b/internal/console/accountdomainspage.go
index 12567e9d1..6b4b5593d 100644
--- a/internal/console/accountdomainspage.go
+++ b/internal/console/accountdomainspage.go
@@ -457,13 +457,24 @@ func domainDNSStatus(state string) string {
return ""
}
+// domainListsPointing reports whether recs hold a pointing record (an A or
+// CNAME a visitor follows), not only required ones (a proof, a delegation).
+func domainListsPointing(recs []dnsRecord) bool {
+ for _, r := range recs {
+ if !r.Required {
+ return true
+ }
+ }
+ return false
+}
+
// domainRecordsToSet is the records a domain registered elsewhere still
// needs at the other registrar: each address's claimDNSAdvice, the advice
// the CLI's domains list gives for the same claim (pointing records with a
// wildcard's delegation, or for a regional claim its delegation alone, and
// a pending claim's proof). An address whose advice is a sentence with no
-// records (no edge addresses known), or a regional one (its pointing is per
-// region), also gets the sentence.
+// pointing records (no edge addresses known, so at most its proof), or a
+// regional one (its pointing is per region), also gets the pointing sentence.
func (s *Server) domainRecordsToSet(ctx context.Context, addrs []domainAddress) ([]domainRecordRow, []string) {
var rows []domainRecordRow
var guidance []string
@@ -479,7 +490,12 @@ func (s *Server) domainRecordsToSet(ctx context.Context, addrs []domainAddress)
c := a.claim
c.Host = a.Host
sentence, _, recs, _ := s.claimDNSAdvice(ctx, c, domainDNSStatus(a.State), *targets)
- if sentence != "" && (len(recs) == 0 || c.Regional()) {
+ if c.Pending && !c.Regional() {
+ // The proof is a row of the table; the sentence that stays is
+ // the pointing advice.
+ sentence = strings.TrimSpace(strings.TrimPrefix(sentence, verifyGuidance(s.domainChallenge(c.Host, c.Account))))
+ }
+ if sentence != "" && (c.Regional() || !domainListsPointing(recs)) {
guidance = append(guidance, sentence)
}
first, last := "", ""
diff --git a/internal/console/accountdomainspage_test.go b/internal/console/accountdomainspage_test.go
index 8fcfdb254..3248493ac 100644
--- a/internal/console/accountdomainspage_test.go
+++ b/internal/console/accountdomainspage_test.go
@@ -6,6 +6,7 @@ package console
import (
"context"
"encoding/json"
+ "html"
"net/http"
"regexp"
"slices"
@@ -646,3 +647,42 @@ func TestDomainPageRegionalPendingListsDelegationOnly(t *testing.T) {
t.Errorf("pending records %q differ from the CLI list's %q", built, cli)
}
}
+
+// A pending claim on a deployment with no edge addresses known has only its
+// proof record to list; the pointing advice is then the sentence, which the
+// page keeps. With pointing records listed, the sentence is left out.
+func TestDomainPagePendingWithoutEdgeIPsKeepsGuidance(t *testing.T) {
+ fx, acct := adFixture(t, consoleFixtureOptions{})
+ fx.srv.cfg.EdgeIPs = nil
+ adApp(t, fx, acct, "a")
+ claim := domains.Claim{Schema: 1, Host: "docs.example.org", Account: acct.Sqid, App: "a", Route: "r.a", Pending: true}
+ adPutClaim(t, fx, claim)
+ c := adSignIn(t, fx, adOwner(acct))
+ ctx := context.Background()
+ targets := fx.srv.dnsTargets(ctx)
+ if len(targets.EdgeIPs) != 0 {
+ t.Fatalf("edge IPs %v, want none", targets.EdgeIPs)
+ }
+ proof := fx.srv.domainChallenge(claim.Host, acct.Sqid)
+
+ if got, want := adRecordsTable(t, fx, c, acct, "example.org"), []string{proof.Name + " TXT " + proof.Value}; !slices.Equal(got, want) {
+ t.Fatalf("records = %q, want %q", got, want)
+ }
+ sentence := `<p class="small">` + html.EscapeString(domainGuidance(claim.Host, targets)) + `</p>`
+ _, body := adGet(t, fx, c, acct, "/domains/example.org")
+ if main := mainOf(t, body); !strings.Contains(main, sentence) {
+ t.Errorf("the pointing sentence is missing beside the proof:\n%s", main)
+ }
+
+ // Edge addresses known: the A record is listed and the sentence is not.
+ fx.srv.cfg.EdgeIPs = []string{"192.0.2.10"}
+ targets = fx.srv.dnsTargets(ctx)
+ _, body = adGet(t, fx, c, acct, "/domains/example.org")
+ main := mainOf(t, body)
+ if !strings.Contains(main, "<td><code>192.0.2.10</code></td>") {
+ t.Errorf("no A record with edge IPs known:\n%s", main)
+ }
+ if strings.Contains(main, html.EscapeString(domainGuidance(claim.Host, targets))) {
+ t.Errorf("the sentence is shown beside its own records:\n%s", main)
+ }
+}