Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

fix(sdk): preserve webhook request compatibility

Yudhi Armyndharis90340ad19df1
diff --git a/scripts/check-contract-shapes.mjs b/scripts/check-contract-shapes.mjs
index fc14f36cc..4e23743cc 100644
--- a/scripts/check-contract-shapes.mjs
+++ b/scripts/check-contract-shapes.mjs
@@ -138,7 +138,6 @@ const MAPPINGS = {
UpsertContactRequest: 'UpsertContactDto',
UpsertLabelRequest: 'UpsertLabelDto',
RedriveWebhookDeliveriesRequest: 'RedriveWebhookDeliveriesDto',
- RedriveWebhookDeliveriesRequest: 'RedriveWebhookDeliveriesDto',
VotePollRequest: 'VotePollDto',
WebhookDeliveryFailure: 'WebhookDeliveryFailureDto',
WebhookFilterCondition: 'WebhookFilterConditionDto',
diff --git a/sdk/go/client_test.go b/sdk/go/client_test.go
index 801ccf152..a6dff3283 100644
--- a/sdk/go/client_test.go
+++ b/sdk/go/client_test.go
@@ -1781,6 +1781,24 @@ func TestSendIdempotencyKey(t *testing.T) {
}
}
+func TestRedrivePreservesAnEmptyIDsFilter(t *testing.T) {
+ rt := &recordTransport{status: 200, body: `{}`}
+ c := newTestClient(t, rt)
+ empty := []string{}
+ for _, ids := range []*[]string{nil, &empty} {
+ if _, err := c.Webhooks.RedriveDeliveryFailures(context.Background(), &RedriveWebhookDeliveriesRequest{IDs: ids}); err != nil {
+ t.Fatal(err)
+ }
+ want := `{}`
+ if ids != nil {
+ want = `{"ids":[]}`
+ }
+ if string(rt.lastRaw) != want {
+ t.Fatalf("body = %s, want %s", rt.lastRaw, want)
+ }
+ }
+}
+
func TestRetryKeepsIdempotencyKey(t *testing.T) {
var keys []string
rt := RoundTripperFunc(func(req *http.Request) (*http.Response, error) {
diff --git a/sdk/go/types_webhook.go b/sdk/go/types_webhook.go
index 3dab58f4f..39f813bd1 100644
--- a/sdk/go/types_webhook.go
+++ b/sdk/go/types_webhook.go
@@ -218,7 +218,8 @@ type RedriveWebhookDeliveriesRequest struct {
// WebhookID limits the batch to one webhook.
WebhookID string `json:"webhookId,omitempty"`
// IDs limits the batch to these failure rows (at most 500).
- IDs []string `json:"ids,omitempty"`
+ // A nil pointer uses the default scope; a pointer to an empty slice replays nothing.
+ IDs *[]string `json:"ids,omitempty"`
// Limit caps the rows replayed by this call (1-500, default 100).
Limit int `json:"limit,omitempty"`
}
diff --git a/sdk/java/src/main/java/com/rmyndharis/openwa/model/RedriveWebhookDeliveriesRequest.java b/sdk/java/src/main/java/com/rmyndharis/openwa/model/RedriveWebhookDeliveriesRequest.java
index 23f206a1f..3a0327e56 100644
--- a/sdk/java/src/main/java/com/rmyndharis/openwa/model/RedriveWebhookDeliveriesRequest.java
+++ b/sdk/java/src/main/java/com/rmyndharis/openwa/model/RedriveWebhookDeliveriesRequest.java
@@ -4,7 +4,7 @@ import java.util.List;
/**
* Request body for replaying recorded webhook deliveries. Every field narrows; {@code null} fields
- * are omitted, and an empty body takes the oldest rows.
+ * are omitted, and an empty body takes the least-retried eligible rows.
*/
public record RedriveWebhookDeliveriesRequest(String sessionId, String webhookId, List<String> ids, Integer limit) {
public static Builder builder() {
diff --git a/sdk/java/src/main/java/com/rmyndharis/openwa/model/WebhookDeliveryFailure.java b/sdk/java/src/main/java/com/rmyndharis/openwa/model/WebhookDeliveryFailure.java
index a4f44d1c8..fea579a3e 100644
--- a/sdk/java/src/main/java/com/rmyndharis/openwa/model/WebhookDeliveryFailure.java
+++ b/sdk/java/src/main/java/com/rmyndharis/openwa/model/WebhookDeliveryFailure.java
@@ -33,4 +33,13 @@ public record WebhookDeliveryFailure(
* redriveDeliveryFailures}: a terminal row (attempts &gt; 0) recorded while the gateway's
* WEBHOOK_FAILURE_PAYLOAD_RETENTION_HOURS is above 0, until that window passes.
*/
- boolean replayable) {}
+ boolean replayable) {
+ /** Preserve construction by clients compiled against the response before replay support. */
+ public WebhookDeliveryFailure(
+ String id, String webhookId, String sessionId, String event, String url,
+ String idempotencyKey, String deliveryId, int attempts, Integer lastStatusCode,
+ String lastError, String createdAt) {
+ this(id, webhookId, sessionId, event, url, idempotencyKey, deliveryId,
+ attempts, lastStatusCode, lastError, createdAt, false);
+ }
+}
diff --git a/sdk/java/src/test/java/com/rmyndharis/openwa/resources/WebhooksResourceTest.java b/sdk/java/src/test/java/com/rmyndharis/openwa/resources/WebhooksResourceTest.java
index 3e8509662..4e83321ee 100644
--- a/sdk/java/src/test/java/com/rmyndharis/openwa/resources/WebhooksResourceTest.java
+++ b/sdk/java/src/test/java/com/rmyndharis/openwa/resources/WebhooksResourceTest.java
@@ -13,6 +13,7 @@ import com.rmyndharis.openwa.model.WebhookEvent;
import com.rmyndharis.openwa.model.WebhookFilterCondition;
import com.rmyndharis.openwa.model.WebhookFilters;
import com.rmyndharis.openwa.model.WebhookRedriveResult;
+import com.rmyndharis.openwa.model.WebhookDeliveryFailure;
import com.rmyndharis.openwa.support.MockTransport;
import java.util.List;
import org.junit.jupiter.api.Test;
@@ -26,6 +27,15 @@ class WebhooksResourceTest {
final OpenWAClient client = new OpenWAClient(
ClientConfig.builder().baseUrl("http://h").apiKey("k").transport(tx).build());
+ @Test
+ void deliveryFailurePreservesThePreviousConstructor() {
+ WebhookDeliveryFailure row = new WebhookDeliveryFailure(
+ "id", "webhook", "session", "message.received", "https://example.test",
+ "key", "delivery", 1, 503, "unavailable", "2026-10-05T00:00:00Z");
+ assertEquals("id", row.id());
+ assertEquals(false, row.replayable());
+ }
+
@Test
void redriveDeliveryFailuresPostsTheFilterOrAnEmptyBody() {
String result =
diff --git a/sdk/javascript/src/types.ts b/sdk/javascript/src/types.ts
index e7969732b..0ea6790cb 100644
--- a/sdk/javascript/src/types.ts
+++ b/sdk/javascript/src/types.ts
@@ -1038,7 +1038,7 @@ export interface WebhookDeliveryFailure {
replayable: boolean;
}
-/** Body of {@link WebhooksResource.redriveDeliveryFailures}. Every field narrows; an empty body takes the oldest rows. */
+/** Body of {@link WebhooksResource.redriveDeliveryFailures}. An empty body takes the least-retried eligible rows. */
export interface RedriveWebhookDeliveriesRequest {
/** Only rows of this session (within the key's allowedSessions). */
sessionId?: string;
@@ -1056,7 +1056,7 @@ export interface WebhookRedriveResult {
redriven: number;
/** Delivered by a direct POST; their failure rows were removed. */
delivered: number;
- /** Handed to the queue; each row is removed when its job delivers and kept if it fails again. */
+ /** Reserved for compatibility; operator redrive always returns zero. */
enqueued: number;
/** Replays that failed again; their rows stay, with attempts raised by one. */
failed: number;
diff --git a/sdk/python/openwa/types.py b/sdk/python/openwa/types.py
index 1e82ac2b0..199283d43 100644
--- a/sdk/python/openwa/types.py
+++ b/sdk/python/openwa/types.py
@@ -1000,7 +1000,7 @@ class WebhookDeliveryFailure(TypedDict):
class RedriveWebhookDeliveriesRequest(TypedDict, total=False):
- """Body of ``WebhooksResource.redrive_delivery_failures``. Every field narrows; an empty body takes the oldest rows."""
+ """Body of ``WebhooksResource.redrive_delivery_failures``. An empty body takes the least-retried eligible rows."""
# Only rows of this session (within the key's allowedSessions).
sessionId: str
@@ -1019,7 +1019,7 @@ class WebhookRedriveResult(TypedDict):
redriven: int
# Delivered by a direct POST; their failure rows were removed.
delivered: int
- # Handed to the queue; each row is removed when its job delivers and kept if it fails again.
+ # Reserved for compatibility; operator redrive always returns zero.
enqueued: int
# Replays that failed again; their rows stay, with attempts raised by one.
failed: int