From e8a4704aa91419e4f3863cfce42d99b60e0b013a Mon Sep 17 00:00:00 2001 From: Brian O'Kelley Date: Thu, 16 Oct 2025 23:23:57 -0400 Subject: [PATCH] Fix AttributeError: Format object has no attribute 'dimensions' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The preview_creative tool was attempting to access format_obj.dimensions as a string attribute, but the Format Pydantic model uses a structured schema where dimensions are stored in the renders field. Changes: - Extract dimensions from format_obj.renders[0].dimensions object - Access width and height as numeric attributes from Dimensions model - Maintain fallback to 300x250 for formats without renders This fixes preview generation for all AdCP formats including display, video, and other format types that specify dimensions through renders. Resolves bug preventing creative preview generation in MCP protocol. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/creative_agent/storage.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/creative_agent/storage.py b/src/creative_agent/storage.py index 849d655..1c32131 100644 --- a/src/creative_agent/storage.py +++ b/src/creative_agent/storage.py @@ -76,14 +76,16 @@ def generate_preview_html(format_obj: Any, manifest: Any, input_set: Any) -> str Returns: HTML string ready to display in iframe """ - # Extract dimensions if available + # Extract dimensions from first render if available width = 300 height = 250 - if format_obj.dimensions: - parts = format_obj.dimensions.split("x") - if len(parts) == 2: - width = int(parts[0]) - height = int(parts[1]) + if format_obj.renders and len(format_obj.renders) > 0: + first_render = format_obj.renders[0] + if first_render.dimensions: + if first_render.dimensions.width is not None: + width = int(first_render.dimensions.width) + if first_render.dimensions.height is not None: + height = int(first_render.dimensions.height) # Get primary image asset image_url = None