-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Cosmos - Change Feed Continuation Token Parsing Bug #43018
Copy link
Copy link
Open
Labels
ClientThis issue points to a problem in the data-plane of the library.This issue points to a problem in the data-plane of the library.CosmosService AttentionWorkflow: This issue is responsible by Azure service team.Workflow: This issue is responsible by Azure service team.customer-reportedIssues that are reported by GitHub users external to the Azure organization.Issues that are reported by GitHub users external to the Azure organization.needs-team-attentionWorkflow: This issue needs attention from Azure service team or SDK teamWorkflow: This issue needs attention from Azure service team or SDK teamquestionThe issue doesn't require a change to the product in order to be resolved. Most issues start as thatThe issue doesn't require a change to the product in order to be resolved. Most issues start as that
Description
Metadata
Metadata
Assignees
Labels
ClientThis issue points to a problem in the data-plane of the library.This issue points to a problem in the data-plane of the library.CosmosService AttentionWorkflow: This issue is responsible by Azure service team.Workflow: This issue is responsible by Azure service team.customer-reportedIssues that are reported by GitHub users external to the Azure organization.Issues that are reported by GitHub users external to the Azure organization.needs-team-attentionWorkflow: This issue needs attention from Azure service team or SDK teamWorkflow: This issue needs attention from Azure service team or SDK teamquestionThe issue doesn't require a change to the product in order to be resolved. Most issues start as thatThe issue doesn't require a change to the product in order to be resolved. Most issues start as that
Type
Projects
StatusShow more project fields
No status
Describe the bug
Using the
ContainerProxy.query_items_change_feedwith thecontinuationfails with a ValueError when provided a valid continuation token returned by Cosmos DB (NoSQL mode). Example error:To Reproduce
Steps to reproduce the behavior:
query_items_change_feedon the container instance with astart_timeparameter supplied.client_connection.last_response_headers["etag"]query_items_change_feedon the container instance with thecontinuationparameter set to the value from 3.Expected behavior
No errors should occur, the change feed query should return expected results, allowing a client to persist the continuation token and pull down further change feed information.
Additional context
This is happening due to bad handling of the continuation token. At
azure/cosmos/_change_feed/change_feed_start_from.py:198, the SDK attempts to parse the point in time with the following:However, the relevant part of the base64 encoded continuation token has the time present as a Unix timestamp in milliseconds, example extracted from a token:
{"Type": "PointInTime", "PointInTimeMs": 1758011093508}The
from_timestampmethod expects a Unix timestamp in seconds. Hence passing the timestamp in milliseconds is causing theValueError. The variable is calledpoint_in_time_mswhich is correct but this is not being used correctly. One possible fix is something like: