Skip to content

WIP#4776

Draft
klssmith wants to merge 2 commits intomainfrom
ks-new-send-letter-endpoint
Draft

WIP#4776
klssmith wants to merge 2 commits intomainfrom
ks-new-send-letter-endpoint

Conversation

@klssmith
Copy link
Copy Markdown
Contributor

No description provided.

@klssmith klssmith force-pushed the ks-new-send-letter-endpoint branch 5 times, most recently from 08a39e8 to 3b8a994 Compare March 23, 2026 14:17
@klssmith klssmith force-pushed the ks-new-send-letter-endpoint branch 3 times, most recently from 46e8757 to 2feb4fc Compare March 30, 2026 09:35
klssmith added 2 commits April 1, 2026 15:55
This changes the `send_letter` method of the `DVLAClient` to send the
letter in a different way - by uploading the file before making the POST
request.

Currently, sending a letter is done in a single request to the
`/v1/print/jobs` endpoint that includes the file.

The new way of sending involves making 3 requests:
1. A GET request to `/v1/print/files/upload-url` to get a presigned URL
2. A PUT request to upload the letter file to the URL returned by step 1
3. A POST request to `/v1/print/jobs` with the `uploadId` from step 1
   included in the request data

These three requests are all made consecutively from the same method,
which means we don't need to store the URL and uploadId from step 1 -
they are used immediately. Any of the stages failing with a retryable
error will result in the whole `deliver_letter` task being retried. It
is possible for a letter to be uploaded successfully at stage 2, then a
failure at stage 3 cause the task to retry and it to be uploaded again
to a new presigned URL before being sent. If a letter is uploaded but there
is no corresponding print request for the uploadId associated with the
presigned URL, the file will not be sent by the DVLA and will get deleted.

Error handling at the new stages of sending a letter
Stage 1 - getting a presigned URL requires authentication so has the same
error handling as making the POST request.

Stage 2 - we don't handle the case of a URL having expired when
uploading a file to it - URLs are valid for 1 hour and the delay between
getting a new URL and using it is seconds at most. We treat rate limit
errors (503s) from this endpoint like any other 5xx status code and
retry. We don't expect to see rate limiting here because we'd hit rate
limiting in stage 1 first.
@klssmith klssmith force-pushed the ks-new-send-letter-endpoint branch from 2feb4fc to a52b733 Compare April 1, 2026 14:56
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.

1 participant