Open garyxuehong opened 10 months ago
799ce05856
)[!TIP] I can email you next time I complete a pull request if you set up your email here!
Here are the GitHub Actions logs prior to making any changes:
2ba9db4
Checking src/sqs/queues.ts for syntax errors... ✅ src/sqs/queues.ts has no syntax errors!
1/1 ✓Checking src/sqs/queues.ts for syntax errors... ✅ src/sqs/queues.ts has no syntax errors!
Sandbox passed on the latest main
, so sandbox checks will be enabled for this issue.
I found the following snippets in your repository. I will now analyze these snippets and come up with a plan.
src/sqs/secret-scanning-alert.ts
✓ https://github.com/garyxuehong/gh4j/commit/b7e8720751f5cc70edd7e5ae9519e295ddd5e1b3 Edit
Create src/sqs/secret-scanning-alert.ts with contents:
• Create a new file `src/sqs/secret-scanning-alert.ts` for the "secret_scanning_alert" message handler.
• Define a new TypeScript type `SecretScanningAlertMessagePayload` that matches the structure of the "secret_scanning_alert" event payload.
• Implement a new function `secretScanningAlertQueueMessageHandler` that contains the logic to process a "secret_scanning_alert" event. This logic should be similar to the existing processing logic in `webhook-receiver-post.ts`.
• Export the `secretScanningAlertQueueMessageHandler` function so it can be used in the `queues.ts` file.
src/sqs/secret-scanning-alert.ts
✓ Edit
Check src/sqs/secret-scanning-alert.ts with contents:
Ran GitHub Actions for b7e8720751f5cc70edd7e5ae9519e295ddd5e1b3:
src/sqs/secret-scanning-alert.test.ts
✓ https://github.com/garyxuehong/gh4j/commit/0ecc70d702d07918740b06deae759626c2d9c5ed Edit
Create src/sqs/secret-scanning-alert.test.ts with contents:
• Create a new test file `src/sqs/secret-scanning-alert.test.ts` for the "secret_scanning_alert" message handler.
• Write tests for the `secretScanningAlertQueueMessageHandler` function to ensure it processes events correctly.
• Use test data that simulates different scenarios of "secret_scanning_alert" events.
src/sqs/secret-scanning-alert.test.ts
✓ Edit
Check src/sqs/secret-scanning-alert.test.ts with contents:
Ran GitHub Actions for 0ecc70d702d07918740b06deae759626c2d9c5ed:
src/sqs/queues.ts
✓ https://github.com/garyxuehong/gh4j/commit/0b7cc97d1b90d9fbf84671116c61eec72df4ec3d Edit
Modify src/sqs/queues.ts with contents:
• Import the `SecretScanningAlertMessagePayload` type and the `secretScanningAlertQueueMessageHandler` function from the newly created `secret-scanning-alert.ts` file.
• Add a new `SqsQueue` instance for "secret_scanning_alert" events to the `sqsQueues` object. Configure it with the appropriate queue name, URL, region, and other settings similar to the existing queues.
• Use the `secretScanningAlertQueueMessageHandler` as the message handler for the new queue.
--- +++ @@ -8,6 +8,7 @@ import { branchQueueMessageHandler } from "./branch"; import { getLogger } from "config/logger"; import type { BackfillMessagePayload, PushQueueMessagePayload, DeploymentMessagePayload, BranchMessagePayload } from "./sqs.types"; +import { SecretScanningAlertMessagePayload, secretScanningAlertQueueMessageHandler } from "./secret-scanning-alert"; import { backfillErrorHandler } from "~/src/sqs/backfill-error-handler"; const LONG_POLLING_INTERVAL_SEC = 3; @@ -75,6 +76,15 @@ webhookMetricWrapper(jiraAndGitHubErrorsHandler, "create") ), + secret_scanning_alert: new SqsQueue({ + queueName: "secret_scanning_alert", + queueUrl: envVars.SQS_SECRET_SCANNING_ALERT_QUEUE_URL, + queueRegion: envVars.SQS_SECRET_SCANNING_ALERT_QUEUE_REGION, + longPollingIntervalSec: LONG_POLLING_INTERVAL_SEC, + timeoutSec: 60, + maxAttempts: 5 + }, secretScanningAlertQueueMessageHandler, webhookMetricWrapper(jiraAndGitHubErrorsHandler, "secret_scanning_alert")), + start: () => { logger.info("Starting queues"); sqsQueues.backfill.start();
src/sqs/queues.ts
✓ Edit
Check src/sqs/queues.ts with contents:
Ran GitHub Actions for 0b7cc97d1b90d9fbf84671116c61eec72df4ec3d:
src/routes/github/webhook/webhook-receiver-post.ts
✓ https://github.com/garyxuehong/gh4j/commit/10b0f1f7f48153da7e730651024ccf5b7d7c5855 Edit
Modify src/routes/github/webhook/webhook-receiver-post.ts with contents:
• Locate the switch case for "secret_scanning_alert" events.
• Instead of processing the "secret_scanning_alert" event directly, enqueue the event to the new "secret_scanning_alert" queue created in `queues.ts`.
• Ensure that the payload passed to the queue matches the `SecretScanningAlertMessagePayload` type.
--- +++ @@ -140,7 +140,7 @@ await GithubWebhookMiddleware(dependabotAlertWebhookHandler)(context); break; case "secret_scanning_alert": - await GithubWebhookMiddleware(secretScanningAlertWebhookHandler)(context); + await sqsQueues.secret_scanning_alert.sendMessage(payload); break; case "installation": if (context.action === "new_permissions_accepted") {
src/routes/github/webhook/webhook-receiver-post.ts
✓ Edit
Check src/routes/github/webhook/webhook-receiver-post.ts with contents:
Ran GitHub Actions for 10b0f1f7f48153da7e730651024ccf5b7d7c5855:
I have finished reviewing the code for completeness. I did not find errors for sweep/put_secret_scanning_alert_events_into_qu
.
💡 To recreate the pull request edit the issue title or description. To tweak the pull request, leave a comment on the pull request.Something wrong? Let us know.
This is an automated message generated by Sweep AI.
The event processing in webhook-receive-post is not putting events "secret_scanning_alert" into queue, like "push" queue in queue.ts. This will risk lost of events "secret_scanning_alert".
Task:
Checklist
- [X] Create `src/sqs/secret-scanning-alert.ts` ✓ https://github.com/garyxuehong/gh4j/commit/b7e8720751f5cc70edd7e5ae9519e295ddd5e1b3 [Edit](https://github.com/garyxuehong/gh4j/edit/sweep/put_secret_scanning_alert_events_into_qu/src/sqs/secret-scanning-alert.ts) - [X] Running GitHub Actions for `src/sqs/secret-scanning-alert.ts` ✓ [Edit](https://github.com/garyxuehong/gh4j/edit/sweep/put_secret_scanning_alert_events_into_qu/src/sqs/secret-scanning-alert.ts) - [X] Create `src/sqs/secret-scanning-alert.test.ts` ✓ https://github.com/garyxuehong/gh4j/commit/0ecc70d702d07918740b06deae759626c2d9c5ed [Edit](https://github.com/garyxuehong/gh4j/edit/sweep/put_secret_scanning_alert_events_into_qu/src/sqs/secret-scanning-alert.test.ts) - [X] Running GitHub Actions for `src/sqs/secret-scanning-alert.test.ts` ✓ [Edit](https://github.com/garyxuehong/gh4j/edit/sweep/put_secret_scanning_alert_events_into_qu/src/sqs/secret-scanning-alert.test.ts) - [X] Modify `src/sqs/queues.ts` ✓ https://github.com/garyxuehong/gh4j/commit/0b7cc97d1b90d9fbf84671116c61eec72df4ec3d [Edit](https://github.com/garyxuehong/gh4j/edit/sweep/put_secret_scanning_alert_events_into_qu/src/sqs/queues.ts#L41-L77) - [X] Running GitHub Actions for `src/sqs/queues.ts` ✓ [Edit](https://github.com/garyxuehong/gh4j/edit/sweep/put_secret_scanning_alert_events_into_qu/src/sqs/queues.ts#L41-L77) - [X] Modify `src/routes/github/webhook/webhook-receiver-post.ts` ✓ https://github.com/garyxuehong/gh4j/commit/10b0f1f7f48153da7e730651024ccf5b7d7c5855 [Edit](https://github.com/garyxuehong/gh4j/edit/sweep/put_secret_scanning_alert_events_into_qu/src/routes/github/webhook/webhook-receiver-post.ts#L27-L150) - [X] Running GitHub Actions for `src/routes/github/webhook/webhook-receiver-post.ts` ✓ [Edit](https://github.com/garyxuehong/gh4j/edit/sweep/put_secret_scanning_alert_events_into_qu/src/routes/github/webhook/webhook-receiver-post.ts#L27-L150)