Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ export default {
...common,
key: "xola-new-order-created-instant",
name: "New Order Created (Instant)",
description: "Emit new event when a new order is created. [See the documentation](https://developers.xola.com/reference/webhook-introduction)",
version: "0.0.1",
description: "Emit new event when a new order is created. [See the documentation](https://developers.xola.com/reference/webhook-introduction). **This source has been deprecated. Please use the 'New Purchase Created (Instant)' source instead.**",
version: "0.0.2",
type: "source",
dedupe: "unique",
methods: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
export default {
...common,
key: "xola-order-deleted-instant",
name: "Order Deleted (Instant)",

Check warning on line 7 in components/xola/sources/order-deleted-instant/order-deleted-instant.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Source names should start with "New". See https://pipedream.com/docs/components/guidelines/#source-name
description: "Emit new event when an order is deleted. [See the documentation](https://developers.xola.com/reference/webhook-introduction)",
version: "0.0.1",
description: "Emit new event when an order is deleted. [See the documentation](https://developers.xola.com/reference/webhook-introduction). **This source has been deprecated. Please use the 'Purchase Canceled (Instant)' source instead.**",
version: "0.0.2",
type: "source",
dedupe: "unique",
methods: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
export default {
...common,
key: "xola-order-updated-instant",
name: "Order Updated (Instant)",

Check warning on line 7 in components/xola/sources/order-updated-instant/order-updated-instant.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Source names should start with "New". See https://pipedream.com/docs/components/guidelines/#source-name
description: "Emit new event when an order is updated. [See the documentation](https://developers.xola.com/reference/webhook-introduction)",
version: "0.0.1",
description: "Emit new event when an order is updated. [See the documentation](https://developers.xola.com/reference/webhook-introduction). **This source has been deprecated. Please use the 'Purchase Updated (Instant)' source instead.**",
version: "0.0.2",
type: "source",
dedupe: "unique",
methods: {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import common from "../common/webhook.mjs";
import sampleEmit from "./test-event.mjs";

export default {
...common,
key: "xola-purchase-canceled-instant",
name: "Purchase Canceled (Instant)",

Check warning on line 7 in components/xola/sources/purchase-canceled-instant/purchase-canceled-instant.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Source names should start with "New". See https://pipedream.com/docs/components/guidelines/#source-name
description: "Emit new event when a purchase is canceled.",
version: "0.0.1",
type: "source",
methods: {
...common.methods,
getEventName() {
return "purchase.cancel";
},
generateMeta(body) {
const { data } = body;
return {
summary: `Purchase Canceled ${data.id}`,
ts: Date.now(),
};
},
Comment on lines +16 to +22
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

Add id field, use payload timestamp, and add error handling.

The generateMeta method needs improvements:

  1. Missing id field: Provides event identification and tracking
  2. Timestamp accuracy: Date.now() reflects processing time, not cancellation time. The payload likely includes a cancellation timestamp that should be used instead
  3. Error handling: No validation for body.data or data.id could cause runtime errors

Apply this diff:

 generateMeta(body) {
   const { data } = body;
+  if (!data?.id) {
+    throw new Error("Invalid webhook payload: missing data.id");
+  }
   return {
+    id: data.id,
     summary: `Purchase Canceled ${data.id}`,
-    ts: Date.now(),
+    ts: data.canceledAt ? Date.parse(data.canceledAt) : Date.now(),
   };
 },

Verify the cancellation timestamp field name in the test event:

Based on learnings about timestamp handling in webhook sources.


🏁 Script executed:

#!/bin/bash
# Check the test event structure for timestamp fields
cat components/xola/sources/purchase-canceled-instant/test-event.mjs | grep -E "(canceledAt|cancelled|canceled|updatedAt|createdAt)" -i

Length of output: 2024



---

🏁 Script executed:

```shell
#!/bin/bash
# Check for other Xola sources to verify timestamp handling patterns
find components/xola/sources -name "*.mjs" -type f | head -5 | while read file; do
  echo "=== $file ==="
  grep -A 10 "generateMeta" "$file" | head -15
done

Length of output: 1164


Add id field and use the correct updatedAt timestamp field from payload.

The generateMeta method needs corrections:

  1. Missing id field: Other Xola sources include composite IDs for event identification
  2. Incorrect timestamp reference: The original suggestion to use data.canceledAt is wrong—this field doesn't exist in the test event. Use data.updatedAt instead (ISO 8601 format: "2025-10-29T07:37:32+00:00"), which reflects when the purchase was canceled
  3. Timestamp conversion: The ISO 8601 updatedAt value needs conversion to milliseconds using Date.parse()

Apply this diff:

 generateMeta(body) {
   const { data } = body;
+  if (!data?.id) {
+    throw new Error("Invalid webhook payload: missing data.id");
+  }
   return {
+    id: `${data.id}-${Date.parse(data.updatedAt)}`,
     summary: `Purchase Canceled ${data.id}`,
-    ts: Date.now(),
+    ts: data.updatedAt ? Date.parse(data.updatedAt) : Date.now(),
   };
 },
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
generateMeta(body) {
const { data } = body;
return {
summary: `Purchase Canceled ${data.id}`,
ts: Date.now(),
};
},
generateMeta(body) {
const { data } = body;
if (!data?.id) {
throw new Error("Invalid webhook payload: missing data.id");
}
return {
id: `${data.id}-${Date.parse(data.updatedAt)}`,
summary: `Purchase Canceled ${data.id}`,
ts: data.updatedAt ? Date.parse(data.updatedAt) : Date.now(),
};
},
🤖 Prompt for AI Agents
In
components/xola/sources/purchase-canceled-instant/purchase-canceled-instant.mjs
around lines 16 to 22, generateMeta is missing an id field and uses the wrong
timestamp; update it to include a composite id (e.g.
`${data.id}:${data.updatedAt}` or follow existing Xola pattern) and set ts to
Date.parse(data.updatedAt) to convert the ISO 8601 updatedAt into milliseconds;
ensure you access data.updatedAt (not data.canceledAt) and handle parsing safely
(e.g. fallback or let invalid parse propagate per project convention).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add only the id as suggested here

},
sampleEmit,
};
Loading
Loading