Skip to content

convert api requests asking for "orderBy=oldest" to the correct value#4469

Merged
andrew-nowak merged 1 commit into
mainfrom
an/safe-parse-oldest-uploadtime-query
Jun 9, 2025
Merged

convert api requests asking for "orderBy=oldest" to the correct value#4469
andrew-nowak merged 1 commit into
mainfrom
an/safe-parse-oldest-uploadtime-query

Conversation

@andrew-nowak

Copy link
Copy Markdown
Member

What does this change?

There's a discrepancy between the search params shown and used by Kahuna, and what's expected in the grid API. One is orderBy - the default (so not shown in the kahuna params) is upload date, from newest to oldest, which the API phrases as -uploadTime. Next is upload date from oldest to newest; kahuna shows this as &orderBy=oldest; but the media API requires uploadTime.

We've had a handful of errors from the media-api from someone trying to order on "oldest", instead of "uploadTime". After some digging I've found the culprit (a service which tries to convert kahuna search params into media-api queries), but rather than fix it there, it's a simple fix to do inside grid itself, to be more resilient to slightly-wrong but still understandable queries.

How should a reviewer test this change?

Make some API queries, ordering on "oldest" - you should get successful requests, instead of 500s. Also/alternatively, paste a grid URL where you've been ordering by "oldest" into pinboard (note not using the "add to pinboard" button, which already does the right thing).

How can success be measured?

Fewer 5xxs

Who should look at this?

Tested? Documented?

  • locally by committer
  • locally by Guardian reviewer
  • on the Guardian's TEST environment
  • relevant documentation added or amended (if needed)

@andrew-nowak andrew-nowak requested a review from a team as a code owner June 6, 2025 11:17

@bryophyta bryophyta left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lgtm!

@prout-bot

Copy link
Copy Markdown

Seen on auth, usage, image-loader, metadata-editor, thrall, leases, cropper, collections, media-api, kahuna (merged by @andrew-nowak 8 minutes and 44 seconds ago) Please check your changes!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants