Skip to content

fix(client): preserve canonical format options in get_products #1005

Closed

Description

@bokelley

Bug

ADCPClient.get_products() in v7.0.0-rc drops valid canonical format_options and can return an empty product list with FORMAT_PROJECTION_FAILED diagnostics.

Reproduction

Return a valid canonical product from an adapter:

TaskResult(
    status=TaskStatus.COMPLETED,
    success=True,
    data={
        "products": [{
            "product_id": "p1",
            "name": "Product 1",
            "description": "A test product",
            "publisher_properties": [
                {"selection_type": "all", "publisher_domain": "pub.example.com"}
            ],
            "format_options": [{
                "format_option_id": "p1-display",
                "format_kind": "image",
                "params": {"width": 300, "height": 250},
            }],
            "delivery_type": "non_guaranteed",
            "pricing_options": [{
                "pricing_model": "cpm",
                "pricing_option_id": "po1",
                "currency": "USD",
            }],
            "reporting_capabilities": {
                "available_reporting_frequencies": ["daily"],
                "expected_delay_minutes": 0,
                "timezone": "UTC",
                "supports_webhooks": False,
                "available_metrics": ["impressions"],
                "date_range_support": "date_range",
            },
        }]
    },
)

Calling the primary get_products() method produces no usable canonical product. Direct GetProductsResponse.model_validate() of the response succeeds.

Root cause

_canonicalize_get_products_result() first parses every response as LegacyGetProductsResponse. The generated legacy ProductFormatDeclaration does not declare canonical format_kind or params, so Pydantic discards them before project_legacy_product() runs. The projector consequently receives entries such as:

{"format_option_id": "p1-display", "canonical_formats_only": false, "experimental": false}

instead of the canonical declaration sent on the wire.

Expected behavior

The primary canonical client should parse a valid canonical GetProductsResponse without passing it through a lossy legacy model. Legacy-only responses should continue through the existing projection path.

Impact

Canonical-only sellers can return a valid wire response while Python v7.0.0-rc buyers silently lose those products. Raw MCP consumers are unaffected; the regression is in the high-level Python client canonicalization path.

Activity

  1. added
    claude-triagingTriage routine is actively working on this issue (1-3 min)
    on Jul 31, 2026
  2. bokelley commented on Jul 31, 2026

    @bokelley
    ContributorAuthor

    Triage

    Classification: Bug
    Bucket(s): client (label not in repo; gap noted in run summary)
    Status: ready-to-implement

    What the experts said:

    • code-reviewer: Root cause confirmed — LegacyProductFormatDeclaration carries extra='ignore' so Pydantic silently drops format_kind/params before projection; the canonical fast-path must also call _remember_canonical_product_routes() and set metadata["projection"] = {"diagnostics": []} for shape consistency; regression test required
    • dx-expert: Silent result.success=True with empty products is a foot-gun; fix direction (canonical-first, legacy fallback) matches the existing dialect-branching pattern already used in list_creatives() and get_media_buys() — and the _creative_dialect() return value at line 1717 is currently discarded rather than branched on, which is the missing wire-up

    My take: Clear v7 regression — _canonicalize_get_products_result() unconditionally routes every wire response through the lossy legacy model, stripping canonical fields before project_legacy_product() runs. The fix is non-breaking and scoped to one method: canonical responses currently fail silently with empty products, so making them work is purely additive.

    Implementation brief:

    • In _canonicalize_get_products_result() (src/adcp/client.py:1503): parse raw_result as GetProductsResponse first; on success, call self._remember_canonical_product_routes(list(canonical.products)) and set metadata["projection"] = {"diagnostics": []} before returning
    • On ValidationError, fall through to the existing LegacyGetProductsResponse projection path unchanged — legacy sellers are unaffected
    • The async polling callsite at client.py:4854 delegates to _canonicalize_get_products_result() directly, so no separate change is needed there; note this in the PR body
    • Add a regression test asserting format_kind and params survive round-trip through _canonicalize_get_products_result() with a canonical wire shape; run pytest -m 'not integration', mypy src/, ruff check ., black --check .

    Triaged by Claude Code. Session: https://claude.ai/code/cse_01AtbrCX2K24YhUf8pR5Mfmi


    Generated by Claude Code

  3. added
    bugSomething isn't working
    and removed
    claude-triagingTriage routine is actively working on this issue (1-3 min)
    on Jul 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions