Skip to content

Conversation

@zhaodongwang-msft
Copy link
Collaborator

@zhaodongwang-msft zhaodongwang-msft commented Nov 24, 2025

tested all examples that they can succeed 3 runs in a row without errors outside of retries

Copilot summary:
This pull request introduces robust retry and backoff logic to the advanced and basic example scripts, improving their reliability when interacting with Dataverse APIs, especially in the face of transient errors or eventual consistency delays. The changes primarily involve wrapping API calls with a backoff helper, adding custom backoff delays for attribute visibility, and enhancing metadata polling. These updates make the scripts more resilient to temporary failures and slow propagation of changes in the Dataverse environment.

Enhanced retry and backoff handling:

  • Introduced a backoff function in both file_upload.py and walkthrough.py to automatically retry API calls on transient errors, using configurable delay intervals and HTTP status codes. All major Dataverse operations (create, update, delete, query, etc.) are now wrapped with this retry logic to handle temporary failures more gracefully. [1] [2]

  • In file_upload.py, added ATTRIBUTE_VISIBILITY_DELAYS and applied custom backoff delays when polling for attribute visibility and during attribute creation, addressing eventual consistency issues in Dataverse metadata propagation. [1] [2] [3]

  • Added a wait_for_attribute_visibility function in file_upload.py to explicitly poll for new attribute availability before proceeding, further reducing errors caused by metadata not being immediately available.

Improved metadata polling and reliability:

  • In functional_testing.py, introduced a wait_for_table_metadata function to poll for table metadata availability after creation, replacing a fixed sleep with a more robust check for actual readiness. This reduces test flakiness due to eventual consistency in table creation. [1] [2]

  • Updated ensure_test_table in functional_testing.py to use the new metadata polling function, ensuring subsequent test steps only proceed when the table is fully available.

General script robustness:

Minor improvements:

  • Added missing imports (time, requests) where necessary to support new logic.
  • Minor type hinting improvement in functional_testing.py. [1] [2]

@zhaodongwang-msft zhaodongwang-msft requested a review from a team as a code owner November 24, 2025 23:33
Copilot AI review requested due to automatic review settings November 24, 2025 23:33
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request enhances the reliability of Dataverse SDK example scripts by introducing comprehensive retry and backoff logic to handle transient errors and eventual consistency delays in the Dataverse environment.

Key Changes:

  • Added backoff helper function to automatically retry API calls on transient HTTP errors with configurable delays
  • Introduced metadata polling functions (wait_for_table_metadata, wait_for_attribute_visibility) to handle eventual consistency issues
  • Wrapped all major Dataverse operations (create, update, delete, query) with retry logic across example scripts

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
src/PowerPlatform/Dataverse/data/_odata.py Enhanced retry logic in _optionset_map method with configurable max attempts and exponential backoff for metadata fetch operations
examples/basic/functional_testing.py Added wait_for_table_metadata polling function and retry logic for all CRUD operations, plus improved cleanup with retry handling
examples/advanced/walkthrough.py Introduced backoff helper function and wrapped all API calls with retry logic for improved resilience
examples/advanced/file_upload.py Added wait_for_attribute_visibility function and applied retry logic to file operations and metadata queries

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@zhaodongwang-msft zhaodongwang-msft merged commit 11eab9f into main Dec 19, 2025
8 checks passed
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.

4 participants