Skip to content

Decode URL-safe job list cursors - #1388

Draft
bgentry wants to merge 1 commit into
masterfrom
bg/fix-job-list-cursor-base64
Draft

bgentry wants to merge 1 commit into
masterfrom
bg/fix-job-list-cursor-base64

Conversation

@bgentry

@bgentry bgentry commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

DRAFT: not ready for review.

Job list cursors from JobListCursor.MarshalText (and so from JobListResult.LastCursor once it's serialized, for example as JSON in an API response) sometimes can't be read back. MarshalText encodes the cursor with the URL-safe base64 alphabet, which uses - and _, but UnmarshalText decodes it with the standard alphabet, which expects + and /. Whenever the encoded cursor happens to contain - or _, decoding fails with an illegal base64 data error and the next page can't be fetched.

Whether that happens depends on the bytes of the cursor's JSON, so it shows up only for some jobs. A cursor for a job whose kind is a~, for example, encodes to text containing -, and passing that text straight back to UnmarshalText fails.

This change decodes with the same URL-safe alphabet used for encoding, so every cursor River produces round-trips. Cursors that decoded before are unaffected, since text without - or _ means the same thing in both alphabets. A new test covers a cursor whose encoded text contains -.

`JobListCursor.MarshalText` emits URL-safe base64, but the decoder uses
the standard alphabet. A job kind that puts `-` or `_` in the encoded
text makes a cursor produced by River fail to round-trip.

Decode with the same URL-safe alphabet used for encoding. Cover a
cursor whose ASCII job kind produces `-` in its text representation.
@bgentry
bgentry force-pushed the bg/fix-job-list-cursor-base64 branch from 2900a21 to d642384 Compare September 25, 2026 15:26
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