Skip to content

Fix video list pagination cursors not encoded with provider metadata - #20710

Merged
Sameerlite merged 1 commit into
BerriAI:litellm_oss_staging_02_08_2026from
tsachis:fix-video-list-pagination-id-encoding
Feb 9, 2026
Merged

Fix video list pagination cursors not encoded with provider metadata#20710
Sameerlite merged 1 commit into
BerriAI:litellm_oss_staging_02_08_2026from
tsachis:fix-video-list-pagination-id-encoding

Conversation

@tsachis

@tsachis tsachis commented Feb 8, 2026

Copy link
Copy Markdown
Contributor

Summary

  • transform_video_list_response: first_id and last_id pagination cursor fields are now encoded with encode_video_id_with_provider(), matching the encoding already applied to data[].id
  • transform_video_list_request: the after parameter is now decoded via extract_original_video_id() before being sent upstream, so wrapped cursor IDs round-trip correctly
  • Added 6 unit tests covering encoding, decoding, passthrough, missing fields, and full round-trip pagination

Fixes #20708

Root Cause

In litellm/llms/openai/videos/transformation.py, transform_video_list_response only iterated over data[] to encode video IDs with provider metadata, but left first_id and last_id as raw provider IDs. Clients using these cursors for pagination would pass unencoded IDs back, breaking provider routing.

Test plan

  • TestVideoListTransformation::test_transform_video_list_response_encodes_first_id_and_last_id — verifies both cursors are encoded
  • TestVideoListTransformation::test_transform_video_list_response_no_provider_leaves_ids_unchanged — no encoding when provider is None
  • TestVideoListTransformation::test_transform_video_list_response_missing_pagination_fields — handles absent first_id/last_id
  • TestVideoListTransformation::test_transform_video_list_request_decodes_after_parameter — encoded after cursor decoded correctly
  • TestVideoListTransformation::test_transform_video_list_request_passes_through_plain_after — plain IDs pass through
  • TestVideoListTransformation::test_transform_video_list_roundtrip — full round-trip: list → use last_id as after → correctly decoded
  • All existing video generation and Azure video transformation tests pass

🤖 Generated with Claude Code

first_id and last_id in the video list response were returned as raw
provider IDs while data[].id was properly wrapped with
encode_video_id_with_provider(). This caused pagination to break when
clients passed unencoded cursors back as the `after` parameter.

- Encode first_id/last_id in transform_video_list_response
- Decode the `after` param in transform_video_list_request via
  extract_original_video_id()
- Add 6 unit tests covering encoding, decoding, passthrough, and
  full round-trip pagination

Fixes BerriAI#20708

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@vercel

vercel Bot commented Feb 8, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
litellm Ready Ready Preview, Comment Feb 8, 2026 2:26pm

Request Review

@CLAassistant

CLAassistant commented Feb 8, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@greptile-apps

greptile-apps Bot commented Feb 8, 2026

Copy link
Copy Markdown
Contributor

Greptile Overview

Greptile Summary

This PR correctly fixes the pagination cursor encoding issue in video list operations. The first_id and last_id fields are now properly encoded with provider metadata to match the encoding already applied to data[].id, and the after parameter is decoded on incoming requests.

Key changes:

  • transform_video_list_response: Encodes first_id and last_id with provider metadata using encode_video_id_with_provider(), extracting the model from the corresponding first/last item in the data array
  • transform_video_list_request: Decodes the after parameter using extract_original_video_id() to unwrap encoded cursor IDs before sending upstream
  • Added 6 comprehensive unit tests covering encoding, decoding, passthrough behavior, missing fields, and full round-trip pagination

The implementation follows the existing pattern used for data[].id encoding and correctly handles edge cases like missing pagination fields and plain (non-encoded) IDs.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The changes are well-isolated to video list pagination logic, follow the existing encoding pattern already used for video IDs, include comprehensive test coverage (6 unit tests covering all edge cases), and fix a legitimate bug where pagination cursors were inconsistent with the encoded video IDs
  • No files require special attention

Important Files Changed

Filename Overview
litellm/llms/openai/videos/transformation.py Adds encoding to first_id and last_id pagination cursors, and decodes after parameter in requests - logic is correct and consistent with existing ID encoding pattern
tests/test_litellm/test_video_generation.py Adds 6 comprehensive unit tests covering encoding/decoding, edge cases, and full round-trip pagination scenarios - excellent test coverage

Sequence Diagram

sequenceDiagram
    participant Client
    participant LiteLLM
    participant OpenAI as OpenAI/Azure Provider

    Note over Client,OpenAI: Video List - First Page Request
    Client->>LiteLLM: GET /v1/videos?limit=10
    LiteLLM->>LiteLLM: transform_video_list_request(after=None)
    LiteLLM->>OpenAI: GET /v1/videos?limit=10
    OpenAI-->>LiteLLM: {data: [{id: "video_aaa"}, {id: "video_bbb"}],<br/>first_id: "video_aaa", last_id: "video_bbb"}
    LiteLLM->>LiteLLM: transform_video_list_response()
    LiteLLM->>LiteLLM: encode data[].id with provider metadata
    LiteLLM->>LiteLLM: encode first_id with provider metadata (NEW)
    LiteLLM->>LiteLLM: encode last_id with provider metadata (NEW)
    LiteLLM-->>Client: {data: [{id: "video_encoded_aaa"}],<br/>first_id: "video_encoded_aaa",<br/>last_id: "video_encoded_bbb"}

    Note over Client,OpenAI: Video List - Next Page Request
    Client->>LiteLLM: GET /v1/videos?after=video_encoded_bbb
    LiteLLM->>LiteLLM: transform_video_list_request(after="video_encoded_bbb")
    LiteLLM->>LiteLLM: extract_original_video_id() → "video_bbb" (NEW)
    LiteLLM->>OpenAI: GET /v1/videos?after=video_bbb
    OpenAI-->>LiteLLM: {data: [{id: "video_ccc"}],<br/>first_id: "video_ccc", last_id: "video_ccc"}
    LiteLLM->>LiteLLM: transform_video_list_response()
    LiteLLM->>LiteLLM: encode pagination cursors with provider metadata
    LiteLLM-->>Client: {data: [{id: "video_encoded_ccc"}],<br/>first_id: "video_encoded_ccc",<br/>last_id: "video_encoded_ccc"}
Loading

@greptile-apps greptile-apps Bot 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.

2 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@Sameerlite
Sameerlite changed the base branch from main to litellm_oss_staging_02_08_2026 February 9, 2026 11:11
@Sameerlite
Sameerlite merged commit 285c00a into BerriAI:litellm_oss_staging_02_08_2026 Feb 9, 2026
6 of 8 checks passed
fzowl pushed a commit to fzowl/litellm that referenced this pull request Jun 24, 2026
…on-id-encoding

Fix video list pagination cursors not encoded with provider metadata
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.

[Bug]: Video list endpoint returns inconsistent ID formats — first_id and last_id pagination cursors are not encoded with provider metadata

3 participants