Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/core/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -2492,9 +2492,11 @@ def model_dump(self, **kwargs):

# Ensure required AdCP fields are present for responses
# (These should be set during package creation/processing)
if data.get("package_id") is None:
# Check the actual object attributes, not the serialized dict,
# because exclude_none=True (default) may exclude None values from the dict
if self.package_id is None:
raise ValueError("Package missing required package_id for AdCP response")
if data.get("status") is None:
if self.status is None:
raise ValueError("Package missing required status for AdCP response")

return data
Expand Down
7 changes: 3 additions & 4 deletions src/core/tools/media_buy_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ def validate_agent_url(url: str | None) -> bool:
Principal,
Product,
Targeting,
TaskStatus,
)
from src.core.testing_hooks import TestingContext, apply_testing_hooks, get_testing_context
from src.core.tool_context import ToolContext
Expand Down Expand Up @@ -1867,8 +1866,8 @@ async def _create_media_buy_impl(
{
"package_id": package_id,
"buyer_ref": pkg.buyer_ref, # Include buyer_ref from request package
# Package status should be null until the package is actually created in the ad server
# After approval + adapter creation, it will be set to "draft" or "active" by the adapter
"status": "draft", # Set initial status (required by AdCP spec)
# Status will be updated to "active" after approval + adapter creation
}
)
pending_packages.append(Package(**pkg_data))
Expand Down Expand Up @@ -2236,7 +2235,7 @@ async def _create_media_buy_impl(
"package_id": package_id,
"name": f"{pkg.product_id} - Package {idx}",
"buyer_ref": pkg.buyer_ref, # Include buyer_ref from request
"status": TaskStatus.INPUT_REQUIRED, # Consistent with TaskStatus enum (requires approval)
"status": "draft", # Package is pending approval (AdCP-compliant status)
}
)

Expand Down
6 changes: 5 additions & 1 deletion tests/e2e/test_schema_validation_standalone.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ async def test_valid_get_products_response():
"name": "Test Display Product",
"description": "Test description",
"publisher_properties": [
{"publisher_domain": "example.com", "property_tags": ["premium_content"]}
{
"publisher_domain": "example.com",
"selection_type": "by_tag",
"property_tags": ["premium_content"],
}
], # Required: publisher properties covered by this product
"format_ids": [
{
Expand Down