BingAds / BingAds-Java-SDK

Other
42 stars 47 forks source link

When deleting PromotionAdExtension, stack traces are written to STDERR #124

Closed schabe77 closed 3 years ago

schabe77 commented 3 years ago

If I delete an PromotionAdExtension via API, reading the response leads to a stack trace that is printed to STDERR due to the usage of magic string delete_value.

java.text.ParseException: Unparseable date: "delete_value"
    at java.base/java.text.DateFormat.parse(DateFormat.java:395)
    at com.microsoft.bingads.v13.internal.bulk.StringExtensions.parseDate(StringExtensions.java:215)
    at com.microsoft.bingads.v13.bulk.entities.BulkPromotionAdExtension$12.accept(BulkPromotionAdExtension.java:153)
    at com.microsoft.bingads.v13.bulk.entities.BulkPromotionAdExtension$12.accept(BulkPromotionAdExtension.java:149)
    at com.microsoft.bingads.v13.internal.bulk.SingleFieldBulkMapping.convertToEntity(SingleFieldBulkMapping.java:32)
    at com.microsoft.bingads.v13.internal.bulk.SimpleBulkMapping.convertToEntity(SimpleBulkMapping.java:16)
    at com.microsoft.bingads.v13.internal.bulk.MappingHelpers.convertToEntity(MappingHelpers.java:21)
    at com.microsoft.bingads.v13.bulk.entities.BulkPromotionAdExtension.processMappingsFromRowValues(BulkPromotionAdExtension.java:370)
    at com.microsoft.bingads.v13.internal.bulk.entities.SingleRecordBulkEntity.readFromRowValues(SingleRecordBulkEntity.java:111)
    at com.microsoft.bingads.v13.internal.bulk.SimpleBulkObjectReader.readNextBulkObject(SimpleBulkObjectReader.java:135)
    at com.microsoft.bingads.v13.internal.bulk.SimpleBulkRecordReader.peek(SimpleBulkRecordReader.java:114)
    at com.microsoft.bingads.v13.internal.bulk.SimpleBulkRecordReader.tryRead(SimpleBulkRecordReader.java:75)
    at com.microsoft.bingads.v13.internal.bulk.SimpleBulkRecordReader.tryRead(SimpleBulkRecordReader.java:56)
    at com.microsoft.bingads.v13.internal.bulk.entities.SingleRecordBulkEntity.readErrors(SingleRecordBulkEntity.java:161)
    at com.microsoft.bingads.v13.internal.bulk.entities.SingleRecordBulkEntity.readRelatedData(SingleRecordBulkEntity.java:145)
    at com.microsoft.bingads.v13.internal.bulk.SimpleBulkRecordReader.tryRead(SimpleBulkRecordReader.java:81)
    at com.microsoft.bingads.v13.internal.bulk.SimpleBulkRecordReader.tryRead(SimpleBulkRecordReader.java:56)
    at com.microsoft.bingads.v13.internal.bulk.SimpleBulkRecordReader.read(SimpleBulkRecordReader.java:32)
    at com.microsoft.bingads.v13.internal.bulk.EntityIterator.readNextBatch(EntityIterator.java:54)
    at com.microsoft.bingads.v13.internal.bulk.EntityIterator.updateNextBatch(EntityIterator.java:46)
    at com.microsoft.bingads.v13.internal.bulk.EntityIterator.hasNext(EntityIterator.java:27)

Please remove all 3 occurrences of

                        } catch (Exception e) {
                                e.printStackTrace();
                        }

(at least if the provided value is the magic string)

qitia commented 3 years ago

@schabe77 , could you please share how do you reproduce this issue? I just do not understand why a datetime for PromotionEnd could be set to 'delete_value'.

schabe77 commented 3 years ago

To reproduce it you need to have a promotion in your account. When you delete it via API the response contains these values.

Here the EntityRecords I received as response for my delete request (I suppose the CampaignServiceInvalidAdExtensionId occurs, because the deleted promotion was still mapped to a campaign).

qitia commented 3 years ago

Can you share a TrackingId/requestid? which you can find from the soap response

schabe77 commented 3 years ago

I just did a delete operation with the Id c7a652b6-d37a-413b-85ae-70bd7a655522

qitia commented 3 years ago

I tried but did not reproduce yet. did you change the PromotionStart/PromotionEnd when you tried to delete that ad extension?

qitia commented 3 years ago

Thanks again @schabe77 for reporting this. I confirm repro the issue. could you please try avoid unset Start/End date when delete promotion ad extension? We will try to send a fix soon.

schabe77 commented 3 years ago

Ah, now I understand! My request already contains this StringTable.DeleteValue because the BulkMapping writes it when the dates are null. Unfortunately the moment I create the delete operation I don't have start and end date.

    private BulkPromotionAdExtension getDeleteOperation(Long promotionId) {
        final PromotionAdExtension promotionAdExtension = new PromotionAdExtension();
        promotionAdExtension.setId(promotionId);
        promotionAdExtension.setStatus(AdExtensionStatus.DELETED);

        final BulkPromotionAdExtension result = new BulkPromotionAdExtension();
        result.setPromotionAdExtension(promotionAdExtension);
        return result;
    }

But because I don't care about deleted entries, as a workaround I can set the PromotionStart and PromotionEnd to a non-null (and non 0/0/0000) value. I tested it and there are no more exceptions printed to my console 👍.

qitia commented 3 years ago

👍 let's keep this issue open until we publish a new version(please expect 13.0.10 soon).

qitia commented 3 years ago

13.0.11 published.