Skip to content

Conversation

@bokelley
Copy link
Contributor

Summary

  • Fixes the issue where tenant's human_review_required setting was not being enforced during media buy creation
  • The code was only checking the adapter's manual_approval_required setting, which could diverge from tenant configuration
  • Now uses tenant's human_review_required as the authoritative source with adapter setting as fallback

Test plan

  • Unit tests added to verify enforcement logic
  • All existing unit tests pass (1260 passed)
  • Integration tests pass (33 passed)
  • integration_v2 tests pass (15 passed)

Closes #845

🤖 Generated with Claude Code

bokelley and others added 6 commits December 22, 2025 17:42
The tenant's human_review_required setting was not being enforced during
media buy creation. The code was only checking the adapter's
manual_approval_required setting, which could be out of sync with the
tenant configuration.

This fix:
- Uses tenant.human_review_required as the authoritative source
- Falls back to adapter setting if tenant allows auto-approval
- Adds debug logging for both settings to aid troubleshooting
- Adds tests to verify the enforcement logic

Also updates type-ignore baseline which was out of sync with main branch.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…cution

These tests need media buy creation to execute immediately (not go to
approval workflow) to properly test pricing validation and response fields.

The fix for issue #845 changed the default behavior to require approval,
which caused these tests to fail because they expected immediate execution
to validate error responses and field presence.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
When using ToolContext (from A2A or direct tool calls), the tenant
context was only being set with {"tenant_id": ...} instead of loading
the full tenant record from the database. This caused the
human_review_required field to be missing, defaulting to True.

Now the context helper attempts to load the full tenant from the
database to get all fields. Falls back to minimal tenant dict if
database is unavailable (e.g., in unit tests).

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…ture

The test fixture was missing human_review_required=False, causing the
media buy creation to go through the approval workflow instead of
executing immediately, which led to database constraint violations.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Use specific exceptions (SQLAlchemyError, RuntimeError) instead of bare
  Exception in context_helpers.py
- Refactor test_tenant_manual_approval_enforcement.py with cleaner structure
  and better docstrings explaining the test strategy

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@bokelley bokelley merged commit 92c562e into main Dec 24, 2025
9 checks passed
This was referenced Dec 24, 2025
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.

Manual approval setting for order activation not enforced when creating media buys

2 participants