Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9639a03bfe |
@@ -72,7 +72,9 @@ func MergeSpeakerMetaJSON(existing string, patch SpeakerMeta) string {
|
||||
if patch.LastDispatchAt != "" {
|
||||
cur.LastDispatchAt = patch.LastDispatchAt
|
||||
}
|
||||
if patch.LastDispatchError != "" {
|
||||
if patch.LastDispatchStatus == "ok" {
|
||||
cur.LastDispatchError = ""
|
||||
} else if patch.LastDispatchError != "" {
|
||||
cur.LastDispatchError = patch.LastDispatchError
|
||||
}
|
||||
if patch.LastDispatchStatus != "" {
|
||||
|
||||
@@ -34,3 +34,24 @@ func TestAgentSyncURL(t *testing.T) {
|
||||
t.Fatalf("got %q", u)
|
||||
}
|
||||
}
|
||||
|
||||
func TestMergeSpeakerMetaJSON_clearsDispatchErrorOnOk(t *testing.T) {
|
||||
t.Parallel()
|
||||
existing := store.SpeakerMetaJSON(store.SpeakerMeta{
|
||||
LastDispatchError: "HTTP 502: bundle 403",
|
||||
LastDispatchStatus: "error",
|
||||
SyncStatus: "error",
|
||||
})
|
||||
merged := store.MergeSpeakerMetaJSON(existing, store.SpeakerMeta{
|
||||
LastDispatchStatus: "ok",
|
||||
SyncStatus: "synced",
|
||||
LastDispatchAt: "2026-05-21T15:06:43Z",
|
||||
})
|
||||
m := store.ParseSpeakerMeta(merged)
|
||||
if m.LastDispatchError != "" {
|
||||
t.Fatalf("LastDispatchError should clear on ok dispatch, got %q", m.LastDispatchError)
|
||||
}
|
||||
if m.LastDispatchStatus != "ok" || m.SyncStatus != "synced" {
|
||||
t.Fatalf("status: dispatch=%q sync=%q", m.LastDispatchStatus, m.SyncStatus)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -277,6 +277,12 @@ export function formatSpeakerError(raw: string | null | undefined): FormattedSpe
|
||||
}
|
||||
|
||||
export function speakerDispatchError(s: SpeakerRow): FormattedSpeakerError | null {
|
||||
const liveRev = s.live?.agent_last_applied_revision_id?.trim();
|
||||
const pub = s.published_revision_id?.trim();
|
||||
// CP meta can keep a stale dispatch error after a later successful agent sync.
|
||||
if (s.live?.agent_ok && liveRev && pub && liveRev === pub) {
|
||||
return null;
|
||||
}
|
||||
return formatSpeakerError(s.last_dispatch_error);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user