kmjennison / dfp-prebid-setup

Automated line item generator for Prebid.js and Google Ad Manager
MIT License
120 stars 74 forks source link

Activate any previously-deleted DFP custom targeting values that we use on line items #31

Open yassineadissa opened 7 years ago

yassineadissa commented 7 years ago

When I run:

python -m tasks.add_new_prebid_partner

I get the following error:

suds.WebFault: Server raised fault: '[CustomTargetingError.DELETED_VALUE_CANNOT_BE_USED_FOR_TARGETING @ targeting.customTargeting.children[0].valueIds; trigger:'447854979471']'

Details:

I installed the script on the server and run it with settings :

PREBID_PRICE_BUCKETS = { 'precision': 2, 'min' : 0.01, 'max' : 20.00, 'increment': 0.01, }

to generate 2000 line items in a single order and then I get the limitation error. After that I deleted the key-values created by the script in the targeting part on UI Access, edited my settings.py and ran the script again . As a result the script showed a dfp exception ('[CustomTargetingError.DELETED_VALUE_CANNOT_BE_USED_FOR_TARGETING @ targeting.customTargeting.children[0].valueIds; trigger:'447854979471']'). Maybe the Id 447854979471 refers to a deleted value, but when I check Ids created on DFP I don't see any value with this ID. Is there any suggestion to repair this issue?

What I think the problem is:

The script affects hb_pb KV values already created and deleted to lineitems, even if there are not part of the list of bids. I think that the created IDs remain linked to the targeted values even if they are deleted.

Here is the entire error, starting from when i ran the command in terminal:

$python -m tasks.add_new_prebid_partner

Going to create 100 new line items.
      Order: AdlivePrebidscript35
      Advertiser: Adlive
      Owner: test-service-account@crypto-gantry-572.iam.gserviceaccount.com

   Line items will have targeting:
      hb_pb = 0.01, 0.02, 0.03, ... 0.98, 0.99, 1.00
      hb_bidder = Appnexus
      placements = ['Adlive_prebid_palcement']

Is this correct? (y/n) y Found user with email "test-service-account@crypto-gantry-572.iam.gserviceaccount.com" and name API service. Found placement with ID "28545565" and name "Adlive_prebid_palcement". Using existing advertiser with ID "4413663824", name "Adlive", and type "AD_NETWORK". Created an order with id "2113121457"" and name "AdlivePrebidscript37". Created creative with ID "138207478576" and name "Appnexus: HB AdlivePrebidscript37, #1". Key "hb_bidder" exists and has 2 existing values. Key "hb_pb" exists and has 500 existing values.

Created a custom targeting value with id "447855102108", name "0.02", and display name "0.02". ... ( Skip the creation of custom targeting values ) Created a custom targeting value with id "447855101658", name "0.98", and display name "0.98". Creating line items... <suds.sax.document.Document instance at 0x7f96a67f0830> Server raised fault in response. Traceback (most recent call last): File "/usr/lib/python2.7/runpy.py", line 162, in _run_module_as_main "main", fname, loader, pkg_name) File "/usr/lib/python2.7/runpy.py", line 72, in _run_code exec code in run_globals File "/var/www/html/Blitz1/adlive/dfp-prebid-setup-master/tasks/add_new_prebid_partner.py", line 360, in main() File "/var/www/html/Blitz1/adlive/dfp-prebid-setup-master/tasks/add_new_prebid_partner.py", line 356, in main currency_code, File "/var/www/html/Blitz1/adlive/dfp-prebid-setup-master/tasks/add_new_prebid_partner.py", line 82, in setup_partner line_item_ids = dfp.create_line_items.create_line_items(line_items_config) File "dfp/create_line_items.py", line 18, in create_line_items line_items = line_item_service.createLineItems(line_items) File "/usr/local/lib/python2.7/dist-packages/googleads/common.py", line 700, in MakeSoapRequest *[_PackForSuds(arg, self.suds_client.factory) for arg in args]) File "/usr/local/lib/python2.7/dist-packages/suds/client.py", line 521, in call return client.invoke(args, kwargs) File "/usr/local/lib/python2.7/dist-packages/suds/client.py", line 581, in invoke result = self.send(soapenv) File "/usr/local/lib/python2.7/dist-packages/suds/client.py", line 619, in send description=tostr(e), original_soapenv=original_soapenv) File "/usr/local/lib/python2.7/dist-packages/suds/client.py", line 670, in process_reply raise WebFault(fault, replyroot) suds.WebFault: Server raised fault: '[CustomTargetingError.DELETED_VALUE_CANNOT_BE_USED_FOR_TARGETING @ targeting.customTargeting.children[0].valueIds; trigger:'447854979471']'

Here is my settings.py:

 import os

ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
GOOGLEADS_YAML_FILE = os.path.join(ROOT_DIR, 'googleads.yaml')

DFP_ORDER_NAME = 'AdlivePrebidscript37'

DFP_USER_EMAIL_ADDRESS = 'test-service-account@crypto-gantry-572.iam.gserviceaccount.com'

DFP_ADVERTISER_NAME = 'Adlive'

DFP_TARGETED_PLACEMENT_NAMES = ['Adlive_prebid_palcement']

DFP_PLACEMENT_SIZES = [
  {
    'width': '300',
    'height': '250'
  },
   {
    'width': '728',
    'height': '90'
  },
   {
    'width': '160',
    'height': '600'
  }

]

DFP_CREATE_ADVERTISER_IF_DOES_NOT_EXIST = True

DFP_USE_EXISTING_ORDER_IF_EXISTS = False

DFP_CURRENCY_CODE = 'MAD'

PREBID_BIDDER_CODE = 'Appnexus'

PREBID_PRICE_BUCKETS = {
  'precision': 2, 
  'min' : 0.01,
  'max' : 1.00,
  'increment': 0.01,
}

try:
    from local_settings import *
except ImportError:
    pass
kmjennison commented 6 years ago

I haven't tested this myself, but I believe we currently mistakenly treat deleted custom targeting values as existing, active values.

Before creating custom targeting values, we first fetch existing values—I think this fetches the deleted values as well. We only create new custom targeting values that aren't returned here.

Instead, we should be sure to also activate any custom targeting values that are deactivated.