Skip to content

Fix batch on-job-complete request not having json body #2409

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

Merged
merged 1 commit into from
Dec 16, 2021
Merged
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
13 changes: 12 additions & 1 deletion pkg/enqueuer/enqueuer.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ type JobSubmission struct {
DelimitedFiles *DelimitedFiles `json:"delimited_files"`
}

type onJobCompleteRequestBody struct {
Message string `json:"message"`
}

func randomMessageID() string {
return random.String(40) // maximum is 80 (for sqs.SendMessageBatchRequestEntry.Id) but this ID may show up in a user error message
}
Expand Down Expand Up @@ -127,10 +131,17 @@ func (e *Enqueuer) Enqueue() (int, error) {
}
}

onJobCompleteBodyBytes, err := json.Marshal(onJobCompleteRequestBody{
Message: "job_complete",
})
if err != nil {
return 0, err
}

randomID := randomMessageID()
_, err = e.aws.SQS().SendMessage(&sqs.SendMessageInput{
QueueUrl: aws.String(e.queueURL),
MessageBody: aws.String("\"job_complete\""),
MessageBody: aws.String(string(onJobCompleteBodyBytes)),
MessageDeduplicationId: aws.String(randomID), // prevent content based deduping
MessageGroupId: aws.String(randomID), // aws recommends message group id per message to improve chances of exactly-once
MessageAttributes: map[string]*sqs.MessageAttributeValue{
Expand Down