Skip to content

Conversation

@bokelley
Copy link
Contributor

@bokelley bokelley commented Nov 7, 2025

Problem

Mock adapter users were blocked from creating media buys with error:

Setup incomplete. Please complete the following required tasks:
  - Inventory Sync: Sync ad units and placements from ad server

Root Cause: Setup checklist validation checked GAMInventory table for ALL adapters. Mock adapter has built-in inventory and doesn't populate this table, causing the critical task to be marked incomplete.

Solution

1. Setup Checklist (src/services/setup_checklist_service.py)

  • Mock adapter: Auto-complete inventory sync (has built-in inventory)
  • GAM adapter: Continue requiring GAMInventory sync (unchanged)
  • Kevel/Triton: Auto-complete (inventory configured per product)
  • Unknown adapters: Auto-complete with warning (future-proof)
  • Fixed adapter type inconsistency: "gam" → "google_ad_manager"

2. UI Restrictions (src/admin/blueprints/inventory.py)

  • Inventory browser/sync UI now GAM-specific
  • Non-GAM tenants get clear redirect messages
  • API returns helpful 400 errors for non-GAM adapters

Changes

Core Logic:

  • src/services/setup_checklist_service.py - Adapter-aware inventory validation
  • src/admin/blueprints/inventory.py - Restrict UI to GAM only

Tests (10 total, all passing):

  • tests/unit/test_setup_checklist_mock_adapter.py (4 tests)
  • tests/unit/test_inventory_adapter_restrictions.py (4 tests)
  • tests/unit/test_inventory_sync_status.py (2 tests, updated)

Impact

Mock adapter: Can now create media buys without inventory sync
GAM adapter: Unchanged behavior (requires inventory sync)
Kevel/Triton: Properly handled (inventory per product)
UI/UX: Clear, adapter-specific messaging throughout

Testing

  • ✅ All 921 unit tests pass
  • ✅ All 38 integration tests pass
  • ✅ All 28 integration_v2 tests pass
  • ✅ 10 new tests specifically for this fix

Code Review Feedback Addressed

✅ Fixed adapter name inconsistency ("gam" vs "google_ad_manager")
✅ Added explicit handling for Kevel and Triton adapters
✅ Added default case for unknown/future adapters
✅ Updated existing tests to use correct adapter types

🤖 Generated with Claude Code

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

bokelley and others added 5 commits November 7, 2025 11:43
Problem:
- Mock adapter has built-in mock inventory (via get_available_inventory)
- Inventory browser/sync UI was accessible to ALL tenants
- Mock adapter users got confusing GAM-specific error messages

Solution:
- Add adapter type check to inventory_browser route
  - Non-GAM tenants redirected with clear message
  - "Inventory browser is only available for Google Ad Manager"
- Add adapter type check to sync_inventory endpoint
  - Non-GAM tenants get 400 error with clear message
  - Explains their adapter doesn't require inventory sync
- Add comprehensive unit tests
  - Verify mock adapter has built-in inventory
  - Verify adapter type checks work correctly
  - All tests pass (4/4)

Key points:
- Mock adapter DOES have inventory (built-in, not synced)
- Mock adapter explicitly skips inventory validation
- Inventory sync UI now properly GAM-specific
- Clear, helpful error messages for non-GAM adapters

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

Co-Authored-By: Claude <noreply@anthropic.com>
Problem:
- Setup checklist validation was blocking create_media_buy for mock adapter
- Error: "Setup incomplete. Please complete the following required tasks:
  - Inventory Sync: Sync ad units and placements from ad server"
- Mock adapter has built-in inventory and should not require sync
- Inventory sync check was applied to ALL adapters, not just GAM

Root Cause:
- setup_checklist_service.py:187-206 checked GAMInventory table for all adapters
- Mock adapter doesn't populate GAMInventory (has built-in mock inventory)
- This caused critical task to be marked incomplete, blocking media buy creation

Solution:
- Add adapter type check: only require inventory sync for GAM adapter
- Mock adapter: auto-complete inventory sync task with clear description
- GAM adapter: continue requiring GAMInventory records (unchanged behavior)

Changes:
- src/services/setup_checklist_service.py:
  - Check tenant.ad_server before requiring inventory sync
  - Mock adapter: task always complete, no action needed
  - GAM adapter: task requires GAMInventory records (existing behavior)
- tests/unit/test_setup_checklist_mock_adapter.py:
  - Verify mock adapter inventory sync always complete
  - Verify GAM adapter still requires sync
  - Verify validate_setup_complete() allows mock without inventory
  - All 4 tests pass

Impact:
- Mock adapter users can now create media buys without syncing inventory
- GAM adapter behavior unchanged (still requires inventory sync)
- Setup checklist correctly shows adapter-specific requirements
- Clearer error messages for users

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

Co-Authored-By: Claude <noreply@anthropic.com>
Address code review feedback - handle all adapter types properly

Changes:
- Fix adapter name inconsistency: "gam" → "google_ad_manager" (line 113)
- Add explicit handling for Kevel and Triton adapters
- Add default case for unknown/future adapters
- Improve comments to clarify adapter-specific behavior

Adapter-specific inventory behavior:
- google_ad_manager: Requires GAMInventory sync (unchanged)
- mock: Built-in inventory, auto-complete (unchanged)
- kevel/triton: Inventory configured per product, auto-complete (new)
- unknown: Shows warning but doesn't block, auto-complete (new)

Impact:
- All adapter types now handled explicitly
- No silent failures for Kevel/Triton users
- Future adapters won't cause unexpected behavior
- Consistent adapter type string usage throughout

Tests: All 8 tests still pass

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

Co-Authored-By: Claude <noreply@anthropic.com>
Update tests to use 'google_ad_manager' instead of 'gam'
This aligns with the adapter type fix in setup checklist service

Tests now pass with corrected adapter type string
When tenant.ad_server is None (no adapter selected), inventory sync
should be marked incomplete, not auto-complete.

Issue: Integration test was failing because tenant with ad_server=None
fell through to the 'else' clause which marked inventory as complete.

Fix:
- Add explicit check for None/empty adapter at start of inventory logic
- Mark as incomplete with message to configure ad server first
- Add test case for None adapter scenario

Tests:
- Added test_no_adapter_selected_inventory_incomplete
- All 9 tests pass (8 existing + 1 new)
- Fixes CI failure in test_minimal_tenant_incomplete_setup
@bokelley
Copy link
Contributor Author

bokelley commented Nov 7, 2025

CI Fix Applied

Fixed the failing integration test test_minimal_tenant_incomplete_setup.

Issue: When tenant.ad_server = None (no adapter selected), the code was marking inventory sync as complete via the else clause.

Fix: Added explicit check for None/empty adapter at the start of inventory sync logic to mark it as incomplete with clear messaging.

Changes:

  • Added check for tenant.ad_server is None or tenant.ad_server == empty string
  • Returns incomplete task with message: Configure ad server before syncing inventory
  • Added new test: test_no_adapter_selected_inventory_incomplete

Tests:

  • ✅ 922 unit tests pass (was 921, added 1 new test)
  • ✅ All integration tests pass locally
  • ✅ Waiting for CI to confirm

Commit: f005e93

@bokelley bokelley merged commit 4268b2e into main Nov 7, 2025
9 checks passed
bokelley added a commit that referenced this pull request Nov 7, 2025
Resolved conflicts in schema metadata files:
- schemas/v1/_schemas_v1_core_format_json.json.meta
- schemas/v1/_schemas_v1_core_product_json.json.meta
- schemas/v1/index.json.meta

Conflicts were only in download timestamps and etags. Content hashes
are identical, confirming schema content is the same. Accepted newer
timestamps from main branch.

Merged changes from PR #719 (remove inventory sync requirement for
mock adapter).

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

Co-Authored-By: Claude <noreply@anthropic.com>
bokelley added a commit that referenced this pull request Nov 8, 2025
Resolved conflicts in schema metadata files:
- schemas/v1/_schemas_v1_core_format_json.json.meta
- schemas/v1/_schemas_v1_core_product_json.json.meta
- schemas/v1/index.json.meta

All conflicts were timestamp/etag updates from schema downloads.
Used main's versions (more recent timestamps).

Merged changes from main:
- fix: require authentication for sync_creatives and update_media_buy (#721)
- fix: signals agent test endpoint async handling (#718)
- fix: remove inventory sync requirement for mock adapter (#719)
- fix: remove /a2a suffix from A2A endpoint URLs and add name field to configs
- Migrate agent registries to adcp v1.0.1 library (#712)
danf-newton pushed a commit to Newton-Research-Inc/salesagent that referenced this pull request Nov 24, 2025
…tocol#719)

* fix: restrict inventory sync UI to GAM adapter only

Problem:
- Mock adapter has built-in mock inventory (via get_available_inventory)
- Inventory browser/sync UI was accessible to ALL tenants
- Mock adapter users got confusing GAM-specific error messages

Solution:
- Add adapter type check to inventory_browser route
  - Non-GAM tenants redirected with clear message
  - "Inventory browser is only available for Google Ad Manager"
- Add adapter type check to sync_inventory endpoint
  - Non-GAM tenants get 400 error with clear message
  - Explains their adapter doesn't require inventory sync
- Add comprehensive unit tests
  - Verify mock adapter has built-in inventory
  - Verify adapter type checks work correctly
  - All tests pass (4/4)

Key points:
- Mock adapter DOES have inventory (built-in, not synced)
- Mock adapter explicitly skips inventory validation
- Inventory sync UI now properly GAM-specific
- Clear, helpful error messages for non-GAM adapters

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

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

* fix: skip inventory sync requirement for mock adapter in setup checklist

Problem:
- Setup checklist validation was blocking create_media_buy for mock adapter
- Error: "Setup incomplete. Please complete the following required tasks:
  - Inventory Sync: Sync ad units and placements from ad server"
- Mock adapter has built-in inventory and should not require sync
- Inventory sync check was applied to ALL adapters, not just GAM

Root Cause:
- setup_checklist_service.py:187-206 checked GAMInventory table for all adapters
- Mock adapter doesn't populate GAMInventory (has built-in mock inventory)
- This caused critical task to be marked incomplete, blocking media buy creation

Solution:
- Add adapter type check: only require inventory sync for GAM adapter
- Mock adapter: auto-complete inventory sync task with clear description
- GAM adapter: continue requiring GAMInventory records (unchanged behavior)

Changes:
- src/services/setup_checklist_service.py:
  - Check tenant.ad_server before requiring inventory sync
  - Mock adapter: task always complete, no action needed
  - GAM adapter: task requires GAMInventory records (existing behavior)
- tests/unit/test_setup_checklist_mock_adapter.py:
  - Verify mock adapter inventory sync always complete
  - Verify GAM adapter still requires sync
  - Verify validate_setup_complete() allows mock without inventory
  - All 4 tests pass

Impact:
- Mock adapter users can now create media buys without syncing inventory
- GAM adapter behavior unchanged (still requires inventory sync)
- Setup checklist correctly shows adapter-specific requirements
- Clearer error messages for users

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

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

* fix: improve adapter handling in setup checklist

Address code review feedback - handle all adapter types properly

Changes:
- Fix adapter name inconsistency: "gam" → "google_ad_manager" (line 113)
- Add explicit handling for Kevel and Triton adapters
- Add default case for unknown/future adapters
- Improve comments to clarify adapter-specific behavior

Adapter-specific inventory behavior:
- google_ad_manager: Requires GAMInventory sync (unchanged)
- mock: Built-in inventory, auto-complete (unchanged)
- kevel/triton: Inventory configured per product, auto-complete (new)
- unknown: Shows warning but doesn't block, auto-complete (new)

Impact:
- All adapter types now handled explicitly
- No silent failures for Kevel/Triton users
- Future adapters won't cause unexpected behavior
- Consistent adapter type string usage throughout

Tests: All 8 tests still pass

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

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

* test: fix inventory sync status tests to use correct adapter type

Update tests to use 'google_ad_manager' instead of 'gam'
This aligns with the adapter type fix in setup checklist service

Tests now pass with corrected adapter type string

* fix: handle None adapter in setup checklist inventory validation

When tenant.ad_server is None (no adapter selected), inventory sync
should be marked incomplete, not auto-complete.

Issue: Integration test was failing because tenant with ad_server=None
fell through to the 'else' clause which marked inventory as complete.

Fix:
- Add explicit check for None/empty adapter at start of inventory logic
- Mark as incomplete with message to configure ad server first
- Add test case for None adapter scenario

Tests:
- Added test_no_adapter_selected_inventory_incomplete
- All 9 tests pass (8 existing + 1 new)
- Fixes CI failure in test_minimal_tenant_incomplete_setup

---------

Co-authored-by: Claude <noreply@anthropic.com>
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