fix(tenant): resolve desktop retry article id via publish record/batch
Fall back to looking up article_id from publish_records or publish_batches
when the desktop task payload lacks article_id at the top level. Covers
payloads that only carry content_ref.{article_id,id}, publish_record_id,
or publish_batch_id, preventing spurious 40096 errors when retrying
older desktop tasks.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
package app
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestResolveRetryArticleIDFromPayload(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
cases := []struct {
|
||||
name string
|
||||
payload map[string]any
|
||||
wantID int64
|
||||
wantOK bool
|
||||
}{
|
||||
{
|
||||
name: "top level article id",
|
||||
payload: map[string]any{
|
||||
"article_id": 78,
|
||||
},
|
||||
wantID: 78,
|
||||
wantOK: true,
|
||||
},
|
||||
{
|
||||
name: "nested content ref article id",
|
||||
payload: map[string]any{
|
||||
"content_ref": map[string]any{
|
||||
"article_id": 79,
|
||||
},
|
||||
},
|
||||
wantID: 79,
|
||||
wantOK: true,
|
||||
},
|
||||
{
|
||||
name: "nested content ref generic id",
|
||||
payload: map[string]any{
|
||||
"content_ref": map[string]any{
|
||||
"id": 80,
|
||||
},
|
||||
},
|
||||
wantID: 80,
|
||||
wantOK: true,
|
||||
},
|
||||
{
|
||||
name: "missing article id",
|
||||
payload: map[string]any{
|
||||
"publish_record_id": 999,
|
||||
},
|
||||
wantID: 0,
|
||||
wantOK: false,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range cases {
|
||||
tc := tc
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
gotID, gotOK := resolveRetryArticleIDFromPayload(tc.payload)
|
||||
if gotID != tc.wantID || gotOK != tc.wantOK {
|
||||
t.Fatalf("resolveRetryArticleIDFromPayload() = (%d, %v), want (%d, %v)", gotID, gotOK, tc.wantID, tc.wantOK)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user