prebid / prebid-mobile-ios

Prebid Mobile SDK for iOS applications
Apache License 2.0
47 stars 88 forks source link

Pathbuilder bug for SDK initialization #802

Closed friar6123 closed 1 year ago

friar6123 commented 1 year ago

Describe the bug The path builder has a bug in it which makes the endpoint URL broken.

To Reproduce Steps to reproduce the behavior:

  1. Prebid.shared.setCustomPrebidServer(url: "https://www.myDomain.com/aCustomPrebidServer/")
  2. Put breakpoint in checkServerStatus in Prebid.swift
  3. Observe serverStatusURLString (https:/status/) is incorrect when compared to server url
  4. Observe SDK fails to initialize because malformed URL

Expected behavior

Should the request URL be this? https://www.myDomain.com/aCustomPrebidServer/status

Screenshots

DEBUG_SCREENSHOT

Desktop (please complete the following information):

YuriyVelichkoPI commented 1 year ago

Hi @friar6123 ! Thanks for the report!

Which SDK version do you use? Unfortunately I can't reproduce the issue.

Also, please, pay attention that in the next release the support of custom server endpoints will be changed as described here: https://github.com/prebid/prebid-mobile-ios/issues/786.

friar6123 commented 1 year ago

I am using 2.0.8

friar6123 commented 1 year ago
Screenshot 2023-03-13 at 10 29 36 AM
YuriyVelichkoPI commented 1 year ago

Have you changed anything in the SDK code? I can reproduce the output only if I change the code in checkServerStatus method to

guard let serverURLHost = URL(string: try Host.shared.getHostURL(host: Prebid.shared.prebidServerHost))?.absoluteString else {
    completion(.failed, PBMError.error(description: "Provided host URL is not valid"))
    return
}
....

Change: the .host was changed to .absoluteString.

In this case I see the same output that you reported. But with original code I still can't reproduce the issue. Unfortunately, this line is not visible on your screenshot in the report.

What version of Xcode and iOS do you use?

friar6123 commented 1 year ago

You are correct, I had changed .host to .absoluteString in an effort to find a solution to the problem. On my end, when I use the original prebid-mobile-ios code (.host) I still see the following problem which is the actual issue I was trying to resolve when I unlocked the cocoapod

The /aCustomPrebidServer goes away and the endpoint requested becomes https://www.mydomain.com/status instead of https://www.mydomain.com/aCustomPrebidServer/status

Do you see this behaviour? xcod 14.2 ios 16 simulator

friar6123 commented 1 year ago

As in, when initializing the sdk with https://www.myDomain.com/aCustomPrebidServer/ the host gets changed to https://www.myDomain.com/

YuriyVelichkoPI commented 1 year ago

I see.

In this case, you should wait for the next release, 2.0.9, and utilize the new property customStatusEndpoint. The details and motivation in #786.

Long story short - Prebid Server doesn't provide any policy for the location of /status endpoint. So SDK can't guess it. And the best solution is just to provide SDK with an actual, complete /status endpoint.

Note: even if SDK signals about initialization error due to the malformed status endpoint, it still works correctly.

In this task's scope, I will review the design of the initialization callback to make a status error notification manageable.

friar6123 commented 1 year ago

Ok gotcha, so even though a swift error is thrown during prebid initialization due to /status failure I can continue to utilize the sdk?

I have not checked yet, but will the same problem with /aCustomPrebidServer at the end of server URL cause the same issue with the other endpoints prebid mobile calls as part of the header bidding process?

friar6123 commented 1 year ago

Is there a timeline for 2.0.9 release?

YuriyVelichkoPI commented 1 year ago
YuriyVelichkoPI commented 1 year ago

Hi @friar6123 ! Is this issue still actual?

friar6123 commented 1 year ago

Hi @YuriyVelichkoPI thank you for your help on this. 2.0.9 status changes worked for our situation