Skip to content

TypeError when generating continuation token - payload not JSON-serializable #44801

@jmathur427

Description

@jmathur427
  • Package Name: azure-core
  • Package Version: Installed via virtual environment (1.38.0)
  • Operating System: macOS 26.2 (25C56)
  • Python Version: 3.13

Describe the bug
A TypeError is raised when the Azure SDK polling framework attempts to generate a continuation token for a long-running operation. The exception indicates that the payload used for token generation is not JSON-serializable, which prevents continuation tokens from being created.
This issue disrupts workflows that rely on resuming, retrying, or persisting long-running operations using continuation tokens.

To Reproduce
Steps to reproduce the behavior:

  1. Execute an Azure SDK operation that uses the polling mechanism (long-running operation).
  2. Allow the operation to reach a point where a continuation token is requested (e.g., calling poller.continuation_token()).
  3. The SDK attempts to serialize the initial response to generate the continuation token.
  4. A runtime exception is thrown.

Exception stack trace:

TypeError: Unable to generate a continuation token for this operation. Payload is not JSON-serializable.

File ".../azure/core/polling/_poller.py", line 283, in continuation_token
    return self._polling_method.get_continuation_token()

File ".../azure/core/polling/_poller.py", line 165, in get_continuation_token
    return _encode_continuation_token(self._initial_response)

File ".../azure/core/polling/_utils.py", line 138, in _encode_continuation_token
    raise TypeError(
        "Unable to generate a continuation token for this operation. "
        "Payload is not JSON-serializable."
    )

Expected behavior
The SDK should either:

  • Gracefully handle non-JSON-serializable fields when generating continuation tokens, or
  • Provide a documented mechanism to customize or override continuation token generation, or
  • Clearly document which operations or payload structures are incompatible with continuation tokens.

At a minimum, the error should provide actionable guidance on how to mitigate or work around the issue.

Additional context

  • This issue occurs at runtime and is not detectable during development or static analysis.
  • The failure prevents safe retry or resume of long-running operations in production environments.
  • The error message does not indicate which part of the response payload is non-serializable, making diagnosis difficult.
  • Guidance on known limitations, recommended workarounds, or planned fixes would be highly appreciated.
  • This issue is coming for begin_delete and begin_create_or_update operations.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Azure.Corecustomer-reportedIssues that are reported by GitHub users external to the Azure organization.needs-author-feedbackWorkflow: More information is needed from author to address the issue.questionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions