- Notifications
You must be signed in to change notification settings - Fork 511
[slack] Choose the correct value for the oldest param #8217
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[slack] Choose the correct value for the oldest param #8217
Conversation
🌐 Coverage report
|
…there's no next page.
| Pinging @elastic/security-external-integrations (Team:Security-External Integrations) |
Do we know that Slack's API will tolerate this param being present? |
bhapas left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should test this against a slack instance to see if the API tolerates the new param
oldest param | The extra parameter will be okay. Infosec ran this request with a real api token and confirmed that it does return results: |
| @chrisberkhout Thanks for checking that. Would you mind including a note in the commit message that this technique is used to stash the value? |
bhapas left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry was a bit late..!
| Package slack - 1.15.1 containing this change is available at https://epr.elastic.co/search?package=slack |
Proposed commit message
API behavior and test scenario explanation
The system test scenario is updated here to match the recently observed behavior of the live API. It attempts to cover all the pagination logic required for non-interrupted operation.
Relevant behavior of the live API includes:
oldestparameter in order to know where to stop, even if acursorparameter is given. In slack: fix handling of oldest parameter when paginating #8169 theoldestparameter was included in all requests, but further changes are required to ensure that its value is correct and does not change for a given sequence of pages..response_metadata.next_cursorfield is always returned, as an empty string if there is no further page.date_createtimestamp. Often this is a few entries, sometimes it is many more.oldestparameter is inclusive, so when a new sequence sets theoldestvalue to the maximumdate_createof the previous sequence, there will be repeated results.date_createandid. The entries returned are ordered bydate_createdescending, but for a givendate_create, theidvalues are not in order.The new scenario is summarized in the following table:
The table's time N and identifier NNN match the system test data's timestamp suffix and ID prefix. The table shows which entry a cursor points to, but cursor values in the test data are random. Green entries are new records for ingestion, red entries are repeated records that we should avoid duplicating.
Without the new fix that scenario fails, having missed entries
3-813and3-212.Things needed for this test to pass:
oldestvalue should be used for each sequence of pages._idto the fingerprintedid).Example request logs from successful system test execution
{ "@timestamp": "2023-11-02T16:59:14.095Z", "message": "HTTP request", "url.query": "limit=2&max_date_seen_so_far=0&oldest=1681664354", "http.response.body.content": null } { "@timestamp": "2023-11-02T16:59:14.096Z", "message": "HTTP response", "url.query": null, "http.response.body.content": [ { "id": "4433a45b-6c7d-8900-e12f-3456789gh0i1", "date_create": 1683836273 }, { "id": "313b13e3-28a3-41f0-9ace-a20952def3a0", "date_create": 1683836273 } ] } { "@timestamp": "2023-11-02T16:59:16.070Z", "message": "HTTP request", "url.query": "cursor=YXNkZmFzZGZhc2Rm&limit=2&max_date_seen_so_far=1683836273&oldest=1681664354", "http.response.body.content": null } { "@timestamp": "2023-11-02T16:59:16.072Z", "message": "HTTP response", "url.query": null, "http.response.body.content": [ { "id": "80928060-1659-4b27-ad55-fdba12e3a7b1", "date_create": 1683836272 }, { "id": "1885fb41-c67c-4cf5-a5c4-d90cb58dd5f9", "date_create": 1683836271 } ] } { "@timestamp": "2023-11-02T16:59:26.077Z", "message": "HTTP request", "url.query": "limit=2&max_date_seen_so_far=1683836273&oldest=1683836273", "http.response.body.content": null } { "@timestamp": "2023-11-02T16:59:26.080Z", "message": "HTTP response", "url.query": null, "http.response.body.content": [ { "id": "4216a45b-6c7d-8900-e12f-3456789gh0i1", "date_create": 1683836274 }, { "id": "412d13e3-28a3-41f0-9ace-a20952def3a0", "date_create": 1683836273 } ] } { "@timestamp": "2023-11-02T16:59:26.081Z", "message": "HTTP request", "url.query": "cursor=GytjmKHF5hFmty&limit=2&max_date_seen_so_far=1683836274&oldest=1683836273", "http.response.body.content": null } { "@timestamp": "2023-11-02T16:59:26.083Z", "message": "HTTP response", "url.query": null, "http.response.body.content": [ { "id": "81328070-1659-4b27-ad55-fdba12e3a7b1", "date_create": 1683836273 }, { "id": "2125fb41-c67c-4cf5-a5c4-d90cb58dd5f9", "date_create": 1683836273 } ] } { "@timestamp": "2023-11-02T16:59:26.084Z", "message": "HTTP request", "url.query": "cursor=Hi4JrvZZnX3IGHE1&limit=2&max_date_seen_so_far=1683836274&oldest=1683836273", "http.response.body.content": null } { "@timestamp": "2023-11-02T16:59:26.085Z", "message": "HTTP response", "url.query": null, "http.response.body.content": [ { "id": "4433a45b-6c7d-8900-e12f-3456789gh0i1", "date_create": 1683836273 }, { "id": "313b13e3-28a3-41f0-9ace-a20952def3a0", "date_create": 1683836273 } ] } { "@timestamp": "2023-11-02T16:59:36.075Z", "message": "HTTP request", "url.query": "limit=2&max_date_seen_so_far=1683836274&oldest=1683836274", "http.response.body.content": null } { "@timestamp": "2023-11-02T16:59:36.077Z", "message": "HTTP response", "url.query": null, "http.response.body.content": [ { "id": "22328080-1659-4b27-ad55-fdba12e3a7b1", "date_create": 1683836275 }, { "id": "4216a45b-6c7d-8900-e12f-3456789gh0i1", "date_create": 1683836274 } ] } { "@timestamp": "2023-11-02T16:59:46.075Z", "message": "HTTP request", "url.query": "limit=2&max_date_seen_so_far=1683836275&oldest=1683836275", "http.response.body.content": null } { "@timestamp": "2023-11-02T16:59:46.077Z", "message": "HTTP response", "url.query": null, "http.response.body.content": [ { "id": "6465fc41-c67c-4cf5-a5c4-d90cb58dd5f9", "date_create": 1683836276 }, { "id": "22328080-1659-4b27-ad55-fdba12e3a7b1", "date_create": 1683836275 } ] } { "@timestamp": "2023-11-02T16:59:56.076Z", "message": "HTTP request", "url.query": "limit=2&max_date_seen_so_far=1683836276&oldest=1683836276", "http.response.body.content": null } { "@timestamp": "2023-11-02T16:59:56.077Z", "message": "HTTP response", "url.query": null, "http.response.body.content": [ { "id": "6465fc41-c67c-4cf5-a5c4-d90cb58dd5f9", "date_create": 1683836276 } ] }Checklist
changelog.ymlfile.How to test this PR locally
Related issues