Skip to content
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

feat/submitter allow retry flag #1134

Merged
merged 11 commits into from
Nov 9, 2023
Merged

Conversation

ziggy-cyb
Copy link
Collaborator

Description

In some instances, it's necessary that a webhook only be tried once in the case that it fails. This feature upgrades the form runner and submitter to accept an allowRetry flag, set to true or false, which determines whether the webhook should be tried more than once.

  • Updated model/schema/schema.ts to allow allowRetry on webhook outputConfiguration.
  • Updated queue-model schema to include a column for allow_retry
  • Updated runner queueService and queueStatusService to pass through the value of allowRetry if it's set on the output, or defaults to true if not
  • Updated submitter to filter out submissions with errors and allow_retry set to false

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce
the testing if necessary.

  • Manual testing with attached form jsons

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation and versioning
  • I have updated the architecture diagrams as per Contribute.md OR added an architectural decision record entry

@@ -17,4 +17,5 @@ model Submission {
return_reference String?
complete Boolean @default(false)
retry_counter Int
allow_retry Boolean
Copy link
Contributor

@jenbutongit jenbutongit Nov 7, 2023

Choose a reason for hiding this comment

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

add the @default(true) annotation and regenerate the migration file (or manually change it). Otherwise when prisma attempt to run the migration on a non-empty table it'll start throwing errors

also congrats @default on the gh handle

data: object,
url?: string,
allowRetry = true
): Promise<QueueResponse> {
const rowData = {
data: JSON.stringify(data),
created_at: new Date(),
updated_at: new Date(),
webhook_url: url ?? null,
Copy link
Contributor

Choose a reason for hiding this comment

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

sorry, I only just spotted this, is this actually nullable / allowed to be null?

we should set url to non optional and webhook_url to non nullable

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ah yeah, I think initially I was thinking every form would put a line in the db and only wanted the ones that have a webhook url to be processed, but you're right we only push in submissions that have webhook urls

/*
Warnings:

- Made the column `webhook_url` on table `Submission` required. This step will fail if there are existing NULL values in that column.
Copy link
Contributor

Choose a reason for hiding this comment

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

mind addressing this warning as well please. default empty string is fine

@ziggy-cyb ziggy-cyb merged commit 49d38b7 into beta Nov 9, 2023
@ziggy-cyb ziggy-cyb deleted the feat/submitter-allow-retry-flag branch November 9, 2023 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants