Skip to content

Conversation

@EmmaLouise2018
Copy link
Contributor

Problem

GAM, Kevel, Triton, and Xandr adapters were not returning packages with package_id in CreateMediaBuyResponse, causing error:

"Adapter did not return package_id for package 0. Cannot build response."

Root Cause

Multiple adapter paths were missing the packages field in CreateMediaBuyResponse:

  • GAM: Manual approval path and activation workflow path
  • Kevel: Missing buyer_ref and packages tracking
  • Triton: Missing buyer_ref and packages tracking
  • Xandr: Using old schema format, wrong method signature

Changes

GAM Adapter (src/adapters/google_ad_manager.py)

  • ✅ Fixed manual approval path to return packages with package_id
  • ✅ Fixed activation workflow path to return packages with package_id and platform_line_item_id
  • ✅ Both paths now properly build package_responses array

Kevel Adapter (src/adapters/kevel.py)

  • ✅ Added buyer_ref to CreateMediaBuyResponse
  • ✅ Track flight IDs for each package in live mode
  • ✅ Build package_responses with package_id and platform_line_item_id

Triton Adapter (src/adapters/triton_digital.py)

  • ✅ Added buyer_ref to CreateMediaBuyResponse
  • ✅ Track flight IDs for each package in live mode
  • ✅ Build package_responses with package_id and platform_line_item_id

Xandr Adapter (src/adapters/xandr.py)

  • ✅ Complete refactor of create_media_buy to new API signature
  • ✅ Migrated from old media_buy= parameter to new request= parameter
  • ✅ Added stub classes for old schemas still used by other methods
  • ✅ Returns buyer_ref and packages with platform_line_item_id
  • ⚠️ Added warning comments about need for full refactor

Testing

Created comprehensive test suites proving all fixes work:

tests/unit/test_adapter_packages_fix.py (5/5 PASSED ✅)

  • ✅ test_kevel_returns_packages_with_package_ids - Dry run mode
  • ✅ test_kevel_live_mode_returns_packages_with_flight_ids - Live mode with flight IDs
  • ✅ test_triton_returns_packages_with_package_ids - Dry run mode
  • ✅ test_triton_live_mode_returns_packages_with_flight_ids - Live mode with flight IDs
  • ✅ test_xandr_returns_packages_with_package_ids_and_line_item_ids - With line item IDs

tests/unit/test_gam_workflow_packages.py (4/4 PASSED ✅)

  • ✅ test_manual_approval_returns_packages_with_package_ids - Manual approval path
  • ✅ test_manual_approval_failure_still_returns_packages - Error handling
  • ✅ test_activation_workflow_returns_packages_with_line_item_ids - Activation workflow path
  • ✅ test_success_path_returns_packages_with_line_item_ids - Success path

Schema Compliance

All adapters now return CreateMediaBuyResponse with:

  • buyer_ref (required)
  • media_buy_id
  • packages array with package_id for each package
  • platform_line_item_id when line items/flights created

Impact

  • Fixes critical bug preventing media buy creation with GAM, Kevel, Triton, and Xandr adapters
  • All adapters now consistently return packages information
  • Full test coverage proves fixes work across all paths

🤖 Generated with Claude Code

Co-Authored-By: Claude noreply@anthropic.com

GAM, Kevel, Triton, and Xandr adapters were not returning packages
with package_id in CreateMediaBuyResponse, causing error:
"Adapter did not return package_id for package 0. Cannot build response."

- Fixed manual approval path to return packages with package_id
- Fixed activation workflow path to return packages with package_id and platform_line_item_id
- Both paths now properly build package_responses array

- Added buyer_ref to CreateMediaBuyResponse
- Track flight IDs for each package in live mode
- Build package_responses with package_id and platform_line_item_id

- Added buyer_ref to CreateMediaBuyResponse
- Track flight IDs for each package in live mode
- Build package_responses with package_id and platform_line_item_id

- Complete refactor of create_media_buy to new API signature
- Migrated from old media_buy= parameter to new request= parameter
- Added stub classes for old schemas still used by other methods
- Returns buyer_ref and packages with platform_line_item_id
- Added warning comments about need for full refactor

Created comprehensive test suites proving all fixes work:

- test_kevel_returns_packages_with_package_ids - Dry run mode
- test_kevel_live_mode_returns_packages_with_flight_ids - Live mode
- test_triton_returns_packages_with_package_ids - Dry run mode
- test_triton_live_mode_returns_packages_with_flight_ids - Live mode
- test_xandr_returns_packages_with_package_ids_and_line_item_ids

- test_manual_approval_returns_packages_with_package_ids - PASSED ✅
- Proves GAM manual approval path fix works

All adapters now return CreateMediaBuyResponse with:
- buyer_ref (required)
- media_buy_id
- packages array with package_id for each package
- platform_line_item_id when line items/flights created

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

Co-Authored-By: Claude <noreply@anthropic.com>
@EmmaLouise2018 EmmaLouise2018 force-pushed the EmmaLouise2018/fix-gam-package-id branch from 78bab53 to e3817a7 Compare October 24, 2025 19:31
@EmmaLouise2018 EmmaLouise2018 merged commit af94df2 into main Oct 24, 2025
8 checks passed
danf-newton pushed a commit to Newton-Research-Inc/salesagent that referenced this pull request Nov 24, 2025
…ouise2018/fix-gam-package-id

Fix all adapters to return packages with package_id
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants