Skip to content

Commit 148a54e

Browse files
committed
fix(telegram): escape pool name in rotate-race hint; assert pool removal
the /pool status hint in the rotate-race message wrote the raw pool name into an HTML-parsed reply, so a name with <,>,& would break rendering; htmlCode it like the other occurrence. The pool-remove test guarded on 'err == nil', which GetPool returns even for a missing pool; assert the pool row is actually gone instead.
1 parent cb095a7 commit 148a54e

2 files changed

Lines changed: 12 additions & 8 deletions

File tree

internal/telegram/commands.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1318,7 +1318,7 @@ func (h *CommandHandler) poolRotate(name string) string {
13181318
var race *poolops.RotateRaceError
13191319
if errors.As(err, &race) {
13201320
return fmt.Sprintf("Pool %s rotate raced a concurrent membership change; nothing was persisted. Re-check the pool with /pool status %s and retry.",
1321-
htmlCode(name), name)
1321+
htmlCode(name), htmlCode(name))
13221322
}
13231323
return fmt.Sprintf("Failed to rotate pool: %v", err)
13241324
}

internal/telegram/commands_test.go

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2172,13 +2172,17 @@ func TestHandlePoolCreateListStatusRotateRemove(t *testing.T) {
21722172
if !strings.Contains(got, "Removed pool") {
21732173
t.Fatalf("pool remove = %q", got)
21742174
}
2175-
if _, err := s.GetPool("codex"); err == nil {
2176-
// GetPool returns (nil, nil) for a missing pool; the status command
2177-
// is the operator-visible "gone" check.
2178-
got = h.Handle(&Command{Name: "pool", Args: []string{"status", "codex"}})
2179-
if !strings.Contains(got, "No pool named") {
2180-
t.Fatalf("status after remove = %q, want not-found", got)
2181-
}
2175+
// GetPool returns (nil, nil) for a missing pool, so assert the pool row
2176+
// is actually gone (p == nil) rather than testing the always-true err.
2177+
if p, err := s.GetPool("codex"); err != nil {
2178+
t.Fatalf("GetPool after remove errored: %v", err)
2179+
} else if p != nil {
2180+
t.Fatalf("pool still present after remove: %+v", p)
2181+
}
2182+
// And the operator-visible status command reports it not-found.
2183+
got = h.Handle(&Command{Name: "pool", Args: []string{"status", "codex"}})
2184+
if !strings.Contains(got, "No pool named") {
2185+
t.Fatalf("status after remove = %q, want not-found", got)
21822186
}
21832187
}
21842188

0 commit comments

Comments
 (0)