Repository navigation
Description
Mismatch
The Python library type for ImageAsset (and sibling asset variants) declares optional fields as nullable:
```python
class ImageAsset(BaseModel):
asset_type: Literal["image"] = "image"
url: str
width: int
height: int
format: str | None = None
alt_text: str | None = None
provenance: Provenance | None = None
```
The bundled JSON schema (`creative/list-creatives-response.json`, AdCP 3.0.6 +) declares the same fields as non-nullable scalar / object types:
```json
"format": { "type": "string" },
"alt_text": { "type": "string" },
"provenance": { "type": "object", ... }
```
Result: an adopter who happily round-trips the typed model and emits the wire envelope via `model_dump()` includes `format: null` / `alt_text: null` / `provenance: null`. The storyboard SDK's bundled-schema validator rejects this — the asset value matches multiple branches of the AssetVariant `oneOf` (or none), depending on validator semantics.
Repro
Storyboard `media_buy_seller/creative_fate_after_cancellation/list_creatives_before_cancel` against an adopter that returns Pydantic-built `ListCreativesResponse` with an image asset that has no format / alt_text / provenance. Validator fails with `Invalid input` at `/creatives/0/assets/`.
Workaround on the adopter side
Strip null-valued fields from each asset value before `model_dump` runs:
```python
assets_dict = {
key: ({k: v for k, v in value.items() if v is not None or k not in _NULL_STRIP_FIELDS}
if isinstance(value, dict) else value)
for key, value in assets_dict.items()
}
```
bokelley/salesagent does this in `src/core/tools/creatives/listing.py`. Workable but every adopter has to do it.
Suggested fix
Two options:
- Match bundled schema: tighten the Pydantic types to non-nullable. Breaking change for adopters constructing models with explicit `None`s.
- Match Pydantic types: relax the bundled schema to allow null. Spec-level change.
Option 1 is the more conservative read — bundled schemas are the authoritative wire contract for compliance grading. Option 2 widens the wire surface and risks downstream consumers (storyboard validator, third-party buyers) tripping on `null` they don't expect.
If option 1: also flip the model_dump default to `exclude_none=True` on the response wrapper so legacy adopters keep emitting valid wire payloads after the type tightening.
Related
- Same null-strip issue likely applies to
VideoAsset.container_format/video_codec/ etc. andUrlAsset.description. - Salesagent issue tracking the workaround removal: list_creatives response: /creatives/0/assets/image does not match list-creatives-response.json schema bokelley/salesagent#274 (closed with the strip in place).
Activity
bokelley commentedon May 10, 2026
Triage
Classification: Bug
Bucket(s): validation, client
Status: drafting-pr
Milestone: omitted
What the experts said:
"type": "string"in JSON Schema Draft 7 disallows null; the Pydantic codegen (datamodel-codegen) incorrectly emitsstr | None = Nonefor non-nullable optional fields. Option 2 (widen schema) has disproportionate blast radius for a codegen bug; the correct fix is on the SDK side._serialize()—_strip_write_only_fields()strips credentials but not None values;sync_creatives_response(),preview_creative_response(), andbuild_creative_response()were completely unguarded. Pydantic model path is clean (exclude_none=Truepropagates correctly through dispatch).format: str | None = NonePython type (correct ergonomics — callers shouldn't need to specify every optional field). Fix serialization layer, not types.My take: All three experts converge on a non-breaking fix: add
_strip_none_values()to the response builder layer and apply it uniformly. The Pydantic types stay nullable for good Python DX; nulls are stripped before wire serialization. Draft PR #631 implements this.Drafting PR: add
_strip_none_values()recursive helper tosrc/adcp/server/responses.pyand apply it in_serialize(),sync_creatives_response(),preview_creative_response(), andbuild_creative_response().Triaged by Claude Code. Session: https://claude.ai/code/session_01AkZRebtF7xsZJZ2FPnQmNL
Generated by Claude Code
fix(server): strip None-valued asset fields from dict-based response …
fix(storyboard): close 4 storyboard failures, wire sync_accounts/list…
fix(server): strip None-valued asset fields from dict-based response …
fix(server): strip None-valued asset fields from dict-based response …
fix(server): strip None-valued asset fields from dict-based response …
fix(server): strip None-valued asset fields from dict-based response …
fix(server): strip None-valued asset fields from dict-based response …