SAP / cloud-sdk-java

Use the SAP Cloud SDK for Java to reduce development effort when building applications on SAP Business Technology Platform that communicate with SAP solutions and services such as SAP S/4HANA Cloud, SAP SuccessFactors, and many others.
Apache License 2.0
22 stars 14 forks source link

Removing sap-client property from detination and setting it manually results in HTTP 400 for OnPremise system requests #550

Closed AnnaLbr closed 2 months ago

AnnaLbr commented 3 months ago

Issue Description

Hello, recently we have been removing the sap-client property from the destination via DefaultHttpDestination.fromDestination(<some-destination>).removeProperty("sap-client").
We are aware that OnPremise systems need this property, so we are setting it manually for each request as query parameter and as header.

To our surprise, all requests to OnPremise systems faild with status 400.
We were startled by this behavior and did not expect it at all. As per this cloud sdk docu, the sap-client header is set automatically if it is present on the destination. Nothing else is mentioned here. But there must be another difference.

I have debugged into this to see what this different is - please see the screenshots:

Header of request with Cloud sdk sap-client header:

DebugWithCloudSDK

Header of request setting sap-client header manually:

DebugNoCloudSDK

Differences I noticed:

  1. sap-client is of type org.apache.http.message.BasicHeader (set manually) and com.sap.cloud.sdk.cloudplatform.connectivity.Header (loud sdk default logic)
  2. Header Proxy-Authorization and SAP-Connectivity-SCC-Location_ID is duplicate for setting header manually, but with the same values

Do you have any idea what else could be going wrong here? Does the cloud-sdk do any additional stuff, other than setting the header?

Impact / Priority

Changing this header logic led to massive issues on our customers side, we had to revert to code and are now analyzing the root issue. However, we dont understand the difference with these two apporaches.

Applicaiton Logs

There is very little application logging. All requests to OnPremise systems simply returned with status 400. No other meaningful massage. Sending requests to the system works with postman.

Maven Dependency tree

mvn-dependency-tree.txt

Project Details

com.sap.cloud.sdk sdk-bom : 5.11.0


Checklist

MatKuhr commented 3 months ago

Hi Anna, sorry you ran into this. This is something I was afraid might happen when discussing the "removeProperty" approach. The problem is that this currently leads to duplicate headers. Now, some systems ignore that, but it seems the cloud connector is more strict and doesn't allow this, even when header values are the same.

We'll look into a workaround / fix.

AnnaLbr commented 3 months ago

Hi again! Thanks for letting me know, so quick as well 😊 Understanding the issue is important for now. We do not need to merge these changes soon.

Feel free to update me if you have a workaroud/fix.

MatKuhr commented 2 months ago

Hi @AnnaLbr, glad to let you know this has been fixed with version 5.12.0. Please let us know if something doesn't work as expected πŸ˜‰

AnnaLbr commented 2 months ago

@MatKuhr Thanks a lot, that didnt take long at all 😊 I will let you know in cases of issues