Ctrl + K
DocumentationLog inGet started

tessl/pypi-google-shopping-merchant-conversions

tessl install tessl/pypi-google-shopping-merchant-conversions@1.0.0

Google Shopping Merchant Conversions API client library for managing conversion sources and tracking.

Agent Success

Agent success rate when using this tile

82%

Improvement

Agent success rate improvement when using this tile compared to baseline

1.17x

Baseline

Agent success rate without this tile

70%

task.mdevals/scenario-9/

Resilient Conversion Source Manager

Build a robust service that manages conversion sources with comprehensive error handling and automatic retry capabilities to ensure reliable operations even when the API experiences transient failures.

Requirements

Your service must handle conversion source creation with the following error resilience features:

Core Functionality

Implement a function create_conversion_source_with_retry that attempts to create a conversion source and automatically retries on failures:

  • Accept merchant account ID, conversion source configuration data, and optional retry parameters
  • Implement exponential backoff retry strategy for transient failures
  • Configure maximum retry attempts (default: 3)
  • Configure initial retry delay (default: 1 second)
  • Use exponential backoff multiplier of 2 (each retry waits 2x longer than the previous)
  • Return the created conversion source on success
  • Raise an appropriate exception after all retries are exhausted

Error Classification

The function must differentiate between error types and handle them appropriately:

  • Transient errors (should trigger retry): Network timeouts, server errors (5xx), rate limiting errors
  • Permanent errors (should NOT retry): Authentication failures, invalid parameters, resource not found errors

Retry Behavior

  • Log each retry attempt with attempt number and delay duration
  • Exponentially increase wait time between retries: 1s, 2s, 4s, etc.
  • Stop retrying immediately on permanent errors
  • Include original error context in the final exception if all retries fail

Rate Limiting Handling

  • Treat rate limiting errors as transient errors that trigger retry logic
  • Use the standard exponential backoff strategy for rate limit errors

Test Cases

  • Creating a conversion source succeeds on first attempt without retries @test
  • Creating a conversion source succeeds after 2 transient failures (server errors) with exponential backoff @test
  • Creating a conversion source fails permanently after authentication error without retry @test
  • Creating a conversion source exhausts all retries and raises final exception with attempt count @test

Implementation

@generates

API

from typing import Dict, Any, Optional
from google.shopping.merchant_conversions_v1beta import ConversionSource

def create_conversion_source_with_retry(
    merchant_id: str,
    conversion_source_data: Dict[str, Any],
    max_retries: int = 3,
    initial_delay: float = 1.0
) -> ConversionSource:
    """
    Create a conversion source with automatic retry on transient failures.

    Args:
        merchant_id: The merchant account ID
        conversion_source_data: Configuration for the conversion source
        max_retries: Maximum number of retry attempts (default: 3)
        initial_delay: Initial delay in seconds before first retry (default: 1.0)

    Returns:
        The created ConversionSource object

    Raises:
        Exception: After all retries are exhausted or on permanent errors
    """
    pass

Dependencies { .dependencies }

google-shopping-merchant-conversions { .dependency }

Provides the API client for managing conversion sources in Google Merchant Center.

@satisfied-by

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/google-shopping-merchant-conversions@1.0.x
tile.json