Skip to content
This repository was archived by the owner on Mar 15, 2026. It is now read-only.

Update to AdCP v2.4.1 with structured renders field - #11

Merged
bokelley merged 2 commits into
mainfrom
fix-format-dimensions
Oct 15, 2025
Merged

Update to AdCP v2.4.1 with structured renders field#11
bokelley merged 2 commits into
mainfrom
fix-format-dimensions

Conversation

@bokelley

Copy link
Copy Markdown
Contributor

Summary

Fixes the 'Format' object has no attribute 'dimensions' error in preview rendering by implementing the new structured renders field from AdCP PR #119.

What Changed

Schema Updates

  • Updated format.json schema with new renders array containing:
    • role: Semantic role of the rendered piece (e.g., "primary", "companion")
    • dimensions: Structured object with width, height, responsive, unit, etc.
  • Regenerated Pydantic models with proper Pydantic v2 syntax

Format Definitions

  • Updated all 26 formats (generative, display, video, DOOH) to use structured renders
  • Created create_fixed_render() helper for non-responsive formats
  • Migrated from requirements={"dimensions": "300x250"} to renders=[create_fixed_render(300, 250)]

Code Updates

  • server.py: Changed preview code from format_obj.requirements["dimensions"] to format_obj.renders[0].dimensions
  • filter_formats(): Now reads from renders array while maintaining backward compatibility with "WxH" string queries
  • Response schema: Added renders field to list_creative_formats response Format

Why This Matters

The old approach buried critical dimension metadata in an unstructured requirements dict with string parsing. The new structured approach provides:

✅ Type-safe access to dimensions
✅ Support for responsive layouts (responsive.width, responsive.height)
✅ Multiple render targets (companion ads, adaptive formats)
✅ Proper units (px, dp, inches, cm)
✅ Aspect ratio constraints
✅ Min/max dimension ranges

This is now properly validated by Pydantic and won't cause AttributeError at runtime.

Test Plan

  • All existing tests pass (57/57)
  • Schema compliance tests validate renders field
  • Manual testing of format.renders access
  • Manual testing of filter_formats with dimensions
  • Backward compatibility: legacy "WxH" dimension strings still work

🤖 Generated with Claude Code

bokelley and others added 2 commits October 15, 2025 05:00
Implements the new renders array from AdCP PR #119, replacing the
unstructured requirements.dimensions string with a proper structured
schema.

Changes:
- Updated format.json schema with renders array containing role and
  dimensions objects
- Regenerated Pydantic models with Dimensions, Render, Responsive,
  and Unit types (fixed Pydantic v2 syntax)
- Updated all 26 formats (generative, display, video, DOOH) to use
  renders field
- Created create_fixed_render helper for non-responsive formats
- Updated server.py preview code to extract dimensions from
  renders[0].dimensions
- Updated filter_formats to use renders for dimension filtering while
  maintaining backward compatibility with "WxH" string format
- Added mypy disable for call-arg errors in standard_formats (Pydantic
  extra='forbid' false positives)

Fixes: 'Format' object has no attribute 'dimensions' error in preview
rendering

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
The CI was failing because manually edited schemas had different formatting
than what the official generate_schemas.py script produces. This commit
regenerates both _schemas_v1_core_format_json.py and
_schemas_v1_creative_list_creative_formats_response_json.py using the
official script to ensure consistent formatting.

Changes:
- Single-quote strings changed to double-quote (PEP 8)
- Annotated types use consistent formatting
- Response schema now includes Render/Dimensions/Unit/Responsive classes
  inline instead of importing from core format (avoids circular deps)

All tests pass (57/57).
@bokelley
bokelley merged commit e5a5219 into main Oct 15, 2025
3 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant