Skip to content

Commit 787d896

Browse files
checkpoint_harmony_endpoint: improve handling of API errors (#13333)
In the generic error handling (including 404 error), clear task ID and page token if any, and reset the sequence for the same timeframe, to avoid getting stuck making requests with stale parameters.
1 parent 7462c4f commit 787d896

File tree

9 files changed

+139
-120
lines changed

9 files changed

+139
-120
lines changed

packages/checkpoint_harmony_endpoint/changelog.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
# newer versions go on top
2+
- version: "0.6.0"
3+
changes:
4+
- description: Improve cleaning of query parameters on errors.
5+
type: enhancement
6+
link: https://github.com/elastic/integrations/pull/13333
27
- version: "0.5.1"
38
changes:
49
- description: Fix endTime query parameter assignment.

packages/checkpoint_harmony_endpoint/data_stream/antibot/agent/stream/cel.yml.hbs

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -150,23 +150,6 @@ program: |
150150
}
151151
)
152152
:
153-
(resp.StatusCode == 404) ?
154-
// 404 Not Found - Resubmit the task ID query for the same timeframe.
155-
state.with(
156-
{
157-
"events": [{"message": {"event": {"reason": "polling"}}.encode_json()}],
158-
"want_more": true,
159-
"cursor": state.cursor.with(
160-
{
161-
"auth_data": auth_data,
162-
"task_id": null,
163-
"next_startTime": state.cursor.current_startTime,
164-
"next_endTime": state.cursor.current_endTime,
165-
}
166-
),
167-
}
168-
)
169-
:
170153
(resp.StatusCode == 200) ?
171154
bytes(resp.Body).decode_json().as(body,
172155
(body.data.state == "Ready") ?
@@ -212,6 +195,7 @@ program: |
212195
)
213196
)
214197
:
198+
// Clear the task ID, and reset the sequence for the same timeframe.
215199
state.with(
216200
{
217201
"events": {
@@ -227,6 +211,14 @@ program: |
227211
},
228212
},
229213
"want_more": false,
214+
"cursor": state.cursor.with(
215+
{
216+
"auth_data": auth_data,
217+
"task_id": null,
218+
"next_startTime": state.cursor.current_startTime,
219+
"next_endTime": state.cursor.current_endTime,
220+
}
221+
),
230222
}
231223
)
232224
)
@@ -315,6 +307,7 @@ program: |
315307
)
316308
)
317309
:
310+
// Clear the task ID and page token, and reset the sequence for the same timeframe.
318311
state.with(
319312
{
320313
"events": {
@@ -330,6 +323,15 @@ program: |
330323
},
331324
},
332325
"want_more": false,
326+
"cursor": state.cursor.with(
327+
{
328+
"auth_data": auth_data,
329+
"task_id": null,
330+
"page_token": null,
331+
"next_startTime": state.cursor.current_startTime,
332+
"next_endTime": state.cursor.current_endTime,
333+
}
334+
),
333335
}
334336
)
335337
)

packages/checkpoint_harmony_endpoint/data_stream/antimalware/agent/stream/cel.yml.hbs

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -150,23 +150,6 @@ program: |
150150
}
151151
)
152152
:
153-
(resp.StatusCode == 404) ?
154-
// 404 Not Found - Resubmit the task ID query for the same timeframe.
155-
state.with(
156-
{
157-
"events": [{"message": {"event": {"reason": "polling"}}.encode_json()}],
158-
"want_more": true,
159-
"cursor": state.cursor.with(
160-
{
161-
"auth_data": auth_data,
162-
"task_id": null,
163-
"next_startTime": state.cursor.current_startTime,
164-
"next_endTime": state.cursor.current_endTime,
165-
}
166-
),
167-
}
168-
)
169-
:
170153
(resp.StatusCode == 200) ?
171154
bytes(resp.Body).decode_json().as(body,
172155
(body.data.state == "Ready") ?
@@ -212,6 +195,7 @@ program: |
212195
)
213196
)
214197
:
198+
// Clear the task ID, and reset the sequence for the same timeframe.
215199
state.with(
216200
{
217201
"events": {
@@ -227,6 +211,14 @@ program: |
227211
},
228212
},
229213
"want_more": false,
214+
"cursor": state.cursor.with(
215+
{
216+
"auth_data": auth_data,
217+
"task_id": null,
218+
"next_startTime": state.cursor.current_startTime,
219+
"next_endTime": state.cursor.current_endTime,
220+
}
221+
),
230222
}
231223
)
232224
)
@@ -315,6 +307,7 @@ program: |
315307
)
316308
)
317309
:
310+
// Clear the task ID and page token, and reset the sequence for the same timeframe.
318311
state.with(
319312
{
320313
"events": {
@@ -330,6 +323,15 @@ program: |
330323
},
331324
},
332325
"want_more": false,
326+
"cursor": state.cursor.with(
327+
{
328+
"auth_data": auth_data,
329+
"task_id": null,
330+
"page_token": null,
331+
"next_startTime": state.cursor.current_startTime,
332+
"next_endTime": state.cursor.current_endTime,
333+
}
334+
),
333335
}
334336
)
335337
)

packages/checkpoint_harmony_endpoint/data_stream/forensics/agent/stream/cel.yml.hbs

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -150,23 +150,6 @@ program: |
150150
}
151151
)
152152
:
153-
(resp.StatusCode == 404) ?
154-
// 404 Not Found - Resubmit the task ID query for the same timeframe.
155-
state.with(
156-
{
157-
"events": [{"message": {"event": {"reason": "polling"}}.encode_json()}],
158-
"want_more": true,
159-
"cursor": state.cursor.with(
160-
{
161-
"auth_data": auth_data,
162-
"task_id": null,
163-
"next_startTime": state.cursor.current_startTime,
164-
"next_endTime": state.cursor.current_endTime,
165-
}
166-
),
167-
}
168-
)
169-
:
170153
(resp.StatusCode == 200) ?
171154
bytes(resp.Body).decode_json().as(body,
172155
(body.data.state == "Ready") ?
@@ -212,6 +195,7 @@ program: |
212195
)
213196
)
214197
:
198+
// Clear the task ID, and reset the sequence for the same timeframe.
215199
state.with(
216200
{
217201
"events": {
@@ -227,6 +211,14 @@ program: |
227211
},
228212
},
229213
"want_more": false,
214+
"cursor": state.cursor.with(
215+
{
216+
"auth_data": auth_data,
217+
"task_id": null,
218+
"next_startTime": state.cursor.current_startTime,
219+
"next_endTime": state.cursor.current_endTime,
220+
}
221+
),
230222
}
231223
)
232224
)
@@ -315,6 +307,7 @@ program: |
315307
)
316308
)
317309
:
310+
// Clear the task ID and page token, and reset the sequence for the same timeframe.
318311
state.with(
319312
{
320313
"events": {
@@ -330,6 +323,15 @@ program: |
330323
},
331324
},
332325
"want_more": false,
326+
"cursor": state.cursor.with(
327+
{
328+
"auth_data": auth_data,
329+
"task_id": null,
330+
"page_token": null,
331+
"next_startTime": state.cursor.current_startTime,
332+
"next_endTime": state.cursor.current_endTime,
333+
}
334+
),
333335
}
334336
)
335337
)

packages/checkpoint_harmony_endpoint/data_stream/threatemulation/agent/stream/cel.yml.hbs

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -150,23 +150,6 @@ program: |
150150
}
151151
)
152152
:
153-
(resp.StatusCode == 404) ?
154-
// 404 Not Found - Resubmit the task ID query for the same timeframe.
155-
state.with(
156-
{
157-
"events": [{"message": {"event": {"reason": "polling"}}.encode_json()}],
158-
"want_more": true,
159-
"cursor": state.cursor.with(
160-
{
161-
"auth_data": auth_data,
162-
"task_id": null,
163-
"next_startTime": state.cursor.current_startTime,
164-
"next_endTime": state.cursor.current_endTime,
165-
}
166-
),
167-
}
168-
)
169-
:
170153
(resp.StatusCode == 200) ?
171154
bytes(resp.Body).decode_json().as(body,
172155
(body.data.state == "Ready") ?
@@ -212,6 +195,7 @@ program: |
212195
)
213196
)
214197
:
198+
// Clear the task ID, and reset the sequence for the same timeframe.
215199
state.with(
216200
{
217201
"events": {
@@ -227,6 +211,14 @@ program: |
227211
},
228212
},
229213
"want_more": false,
214+
"cursor": state.cursor.with(
215+
{
216+
"auth_data": auth_data,
217+
"task_id": null,
218+
"next_startTime": state.cursor.current_startTime,
219+
"next_endTime": state.cursor.current_endTime,
220+
}
221+
),
230222
}
231223
)
232224
)
@@ -315,6 +307,7 @@ program: |
315307
)
316308
)
317309
:
310+
// Clear the task ID and page token, and reset the sequence for the same timeframe.
318311
state.with(
319312
{
320313
"events": {
@@ -330,6 +323,15 @@ program: |
330323
},
331324
},
332325
"want_more": false,
326+
"cursor": state.cursor.with(
327+
{
328+
"auth_data": auth_data,
329+
"task_id": null,
330+
"page_token": null,
331+
"next_startTime": state.cursor.current_startTime,
332+
"next_endTime": state.cursor.current_endTime,
333+
}
334+
),
333335
}
334336
)
335337
)

packages/checkpoint_harmony_endpoint/data_stream/threatextraction/agent/stream/cel.yml.hbs

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -150,23 +150,6 @@ program: |
150150
}
151151
)
152152
:
153-
(resp.StatusCode == 404) ?
154-
// 404 Not Found - Resubmit the task ID query for the same timeframe.
155-
state.with(
156-
{
157-
"events": [{"message": {"event": {"reason": "polling"}}.encode_json()}],
158-
"want_more": true,
159-
"cursor": state.cursor.with(
160-
{
161-
"auth_data": auth_data,
162-
"task_id": null,
163-
"next_startTime": state.cursor.current_startTime,
164-
"next_endTime": state.cursor.current_endTime,
165-
}
166-
),
167-
}
168-
)
169-
:
170153
(resp.StatusCode == 200) ?
171154
bytes(resp.Body).decode_json().as(body,
172155
(body.data.state == "Ready") ?
@@ -212,6 +195,7 @@ program: |
212195
)
213196
)
214197
:
198+
// Clear the task ID, and reset the sequence for the same timeframe.
215199
state.with(
216200
{
217201
"events": {
@@ -227,6 +211,14 @@ program: |
227211
},
228212
},
229213
"want_more": false,
214+
"cursor": state.cursor.with(
215+
{
216+
"auth_data": auth_data,
217+
"task_id": null,
218+
"next_startTime": state.cursor.current_startTime,
219+
"next_endTime": state.cursor.current_endTime,
220+
}
221+
),
230222
}
231223
)
232224
)
@@ -315,6 +307,7 @@ program: |
315307
)
316308
)
317309
:
310+
// Clear the task ID and page token, and reset the sequence for the same timeframe.
318311
state.with(
319312
{
320313
"events": {
@@ -330,6 +323,15 @@ program: |
330323
},
331324
},
332325
"want_more": false,
326+
"cursor": state.cursor.with(
327+
{
328+
"auth_data": auth_data,
329+
"task_id": null,
330+
"page_token": null,
331+
"next_startTime": state.cursor.current_startTime,
332+
"next_endTime": state.cursor.current_endTime,
333+
}
334+
),
333335
}
334336
)
335337
)

0 commit comments

Comments
 (0)