Skip to content

Conversation

@EmmaLouise2018
Copy link
Contributor

Summary

This PR fixes multiple issues with media buy creation, package data consistency, and status reporting across auto-approved and manually-approved workflows.

Changes

1. Fixed Package Data Consistency (Auto-Approve vs Manual Approve)

Problem: Manual approval responses returned minimal package data (only 4 fields), while auto-approval returned complete data (budget, targeting, creative_ids, etc.).

Fix: Both manual approval paths now serialize the full package object using model_dump_internal() to return consistent, complete data.

Files Changed:

  • src/core/main.py (lines 4817-4833, 4987-5003)

Impact: Buying agents now receive consistent package data regardless of approval path.


2. Added Package Data Fields to Auto-Approval Path

Problem: Auto-approved media buys weren't saving product_id, budget, and targeting_overlay to MediaPackage records, causing incomplete display in UI and inconsistent responses.

Fix:

  • Added product_id and budget fields to MediaPackage schema
  • Populated these fields from request packages during auto-approval
  • Updated database package_config to include full package data

Files Changed:

  • src/core/schemas.py (MediaPackage class)
  • src/core/main.py (lines 5162-5188)

Impact: Auto-approved packages now have complete metadata in database and responses.


3. Fixed Package Status Logic for Creative Approval

Problem: Package status was set to COMPLETED when creatives were assigned, even if they were still pending approval.

Fix: Status now correctly reflects creative approval state:

  • INPUT_REQUIRED: Manual approval needed
  • WORKING: Creatives still needed or pending approval
  • COMPLETED: Creatives assigned AND approved

Files Changed:

  • src/core/main.py (lines 5442-5452)

Impact: Buying agents can now accurately determine if a media buy is truly ready.


4. Standardized TaskStatus Enum Usage

Problem: Manual approval paths used string literal "pending_approval" instead of proper TaskStatus enum.

Fix: Replaced all string status literals with TaskStatus.INPUT_REQUIRED enum value.

Files Changed:

  • src/core/main.py (lines 4821, 4991, 5002)

Impact: Consistent status values across all response types.


5. Fixed Template Package Display

Problem: Media buy detail template tried to access package fields directly, but they're stored in package_config JSONB.

Fix: Updated template to access fields via package.package_config.get().

Files Changed:

  • templates/media_buy_detail.html (lines 128-148)

Impact: Package details now display correctly for both approval paths.


6. Added Creative ID Display to Review Page

Problem: Creative review cards didn't show the creative_id, making it hard to identify which creative to approve.

Fix: Added creative_id display below the creative name in monospace font.

Files Changed:

  • templates/creative_management.html (lines 71-73)

Impact: Easier identification of creatives during review.


Testing Notes

All fixes have been tested locally with Docker restart. Changes affect:

  • ✅ Manual approval media buy responses
  • ✅ Auto-approval media buy responses
  • ✅ Package data consistency
  • ✅ Creative status handling
  • ✅ Admin UI package display

Breaking Changes

None - all changes are backwards compatible and fix existing inconsistencies.

@gitguardian
Copy link

gitguardian bot commented Oct 24, 2025

⚠️ GitGuardian has uncovered 1 secret following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secret in your pull request
GitGuardian id GitGuardian status Secret Commit Filename
21837872 Triggered Generic High Entropy Secret d00a082 scripts/test-sales-agent-local-mcp.sh View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secret safely. Learn here the best practices.
  3. Revoke and rotate this secret.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

@EmmaLouise2018 EmmaLouise2018 merged commit 0a51476 into main Oct 24, 2025
8 checks passed
bokelley added a commit that referenced this pull request Oct 24, 2025
Brings in:
- CORS middleware for A2A endpoints (#602)
- Inventory sync background service improvements (#603)
- Various UI and template improvements
danf-newton pushed a commit to Newton-Research-Inc/salesagent that referenced this pull request Nov 24, 2025
…ouise2018/clean-package-fixes

fix: sales agent logic
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