Repository navigation
Closed
Description
Observed
3.2 → 3.1 conversion (#1559) produces payloads that the 3.1 schema refuses.
1. A notification config whose events are all 3.2-only keeps an empty event_types
3.1 requires minItems: 1.
from adcp.compat.versions import convert_payload
accounts = {
"accounts": [
{
"account_id": "a1",
"name": "Acct",
"status": "active",
"notification_configs": [
{"subscriber_id": "s", "url": "https://x.example/h", "event_types": ["account.change_recorded"]}
],
}
]
}
result = convert_payload("list_accounts", accounts, direction="sync", source_version="3.2", target_version="3.1")
print("event_types:", result.payload["accounts"][0]["notification_configs"][0].get("event_types"))AdCP conversion 3.2 -> 3.1 dropped /accounts/0/notification_configs/0/event_types/0 (enum_unavailable)
event_types: []
2. Structured geo_regions capability becomes {}
3.2 allows a boolean or a geo-region-support object; 3.1 allows only a boolean.
from adcp.compat.versions import convert_payload
capabilities = {
"adcp": {"major_versions": [3], "supported_versions": ["3.1", "3.2"]},
"supported_protocols": ["media_buy"],
"media_buy": {
"execution": {
"targeting": {
"geo_countries": True,
"geo_regions": {"countries": {"US": {"values": ["US-NY", "US-CA"]}}},
"geo_postal_areas": {"US": ["zip"]},
}
}
},
}
result = convert_payload(
"get_adcp_capabilities", capabilities, direction="sync", source_version="3.2", target_version="3.1"
)
print("3.1 targeting:", result.payload["media_buy"]["execution"]["targeting"])
print("losses:", [(loss.pointer, loss.reason) for loss in result.losses])3.1 targeting: {'geo_countries': True, 'geo_regions': {}, 'geo_postal_areas': {'US': ['zip']}}
losses: [('/media_buy/execution/targeting/geo_regions/countries', 'field_unavailable')]
Expected
- Notification config: a config left with no 3.1 event types is dropped from the converted payload, with the loss recorded, rather than emitted invalid.
geo_regions: a structured declaration with any supported country converts totrue. That's the coarse 3.1 meaning: the seller supports region targeting somewhere.
More generally, converted responses could be validated against the target version before they're returned, so a conversion that can't be represented fails as a structured conversion error instead of reaching the buyer invalid.
Impact
Found while moving the Embedded Sales Agent's own 3.1 projections onto the SDK's conversion. ESA keeps a reduced _accounts_for_release and its targeting_for_release because of these two cases.
Metadata
Metadata
Assignees
Labels
No labels
Activity
fix(compat): never downgrade into a payload the older schema refuses (#…