Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: stop method property from being mandatory for push http transfers #3797

Conversation

ndr-brt
Copy link
Member

@ndr-brt ndr-brt commented Jan 24, 2024

What this PR changes/adds

The method property was mandatory when the proxyMethod was true, but, in fact, also if a source DataAddress defines that property, it could be that the same asset is used in a PUSH type transfer, this fix permits to do that by adding an additional check.

Why it does that

fix bug

Further notes

  • in the future (see dataplane signaling DR) this information will be taken out from the transferType field that will be mandatory, while the dataDestination won't be supplied for pull transfers.

Linked Issue(s)

Closes #3768

Please be sure to take a look at the contributing guidelines and our etiquette for pull requests.

@ndr-brt ndr-brt added bug Something isn't working dpf Feature related to the Data Plane Framework labels Jan 24, 2024
@ndr-brt ndr-brt requested a review from wolf4ood January 24, 2024 11:09
@@ -53,7 +53,7 @@ public HttpRequestParams.Builder decorate(DataFlowRequest request, HttpDataAddre
}

private @NotNull String extractMethod(HttpDataAddress address, DataFlowRequest request) {
if (Boolean.parseBoolean(address.getProxyMethod())) {
if (Boolean.parseBoolean(address.getProxyMethod()) && "HttpProxy".equals(request.getDestinationDataAddress().getType())) {
Copy link

@efiege efiege Jan 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't expect that this will solve the issue regarding the HttpPush. This will disable the feature of proxying http methods for the HttpPush, as now just "GET" requests will be sent to the providing backend.

Our expectation would be that http-methods also could be proxied for the HttpPush. We could also help providing this fix, if this is more convenient.

Copy link
Member Author

@ndr-brt ndr-brt Jan 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

simply, for http push this condition won't ever met, and it will pass through line 60, so the method will be taken from the DataAddress (as it already does) if it's defined, otherwise it will use the default GET.

To verify that, just try to remove the proxyMethod property and set method instead on the source data address.

The proxy was made to work with pull, not for push

Copy link

@efiege efiege Jan 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

simply, for http push this condition won't ever met, and it will pass through line 60, so the method will be taken from the DataAddress (as it already does) if it's defined, otherwise it will use the default GET.

Ohh yes, I have overlooked this: The HttpPush will use the method from the DataAddress.

The proxy was made to work with pull, not for push

This would implicate that certain HttpData assets can just be used for HttpProxy transfer-types and not for HttpData transfer-types. However it would make sense to also support this for the HttpPush.

So basically this would be a feature request?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

theoretically yes, I'm not sure which would be the applications for that: the consumer should be the one who chose how the call to its service will be made.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The applications would be the same as for the http-pull I think.

So for the http-pull the consumer is able to select the preferred http-method, which is used to access the provider system. This is enabled by using the prxoyMethod=true property in the asset of the provider.

For the http-push the transfer is also started by the consumer. Like for the http-pull the consumer should be able to select the prefered http-method, which is used to access the provider system.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in any case, also without the proxyMethod flag to true, the consumer can choose the method, that by default is GET. Really, all the proxyXXX stuff is there for the proxy use case ("nomen omen").

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @ndr-brt,

I'm sry for coming back on this so lately, but this change is really important to us and I may not have understood this correctly.

After giving this a second look, I am also convinced, that this change won't affect passing methods for the HttpPush from the consumer.

My problem was, that I though the HttpDataAddress address parameter is always populated by the SourceDataAddress:

private @NotNull String extractMethod(HttpDataAddress address, DataFlowStartMessage request) {
if (Boolean.parseBoolean(address.getProxyMethod()) && "HttpProxy".equals(request.getDestinationDataAddress().getType())) {
return Optional.ofNullable(request.getProperties().get(METHOD))
.orElseThrow(() -> new EdcException(format("DataFlowRequest %s: 'method' property is missing", request.getId())));
}
return Optional.ofNullable(address.getMethod()).orElse(DEFAULT_METHOD);
}

but it turns out it also gets called for the DestinationDataAddress:

@Override
public HttpRequestParams provideSourceParams(DataFlowStartMessage request) {
var params = HttpRequestParams.Builder.newInstance();
var address = HttpDataAddress.Builder.newInstance().copyFrom(request.getSourceDataAddress()).build();
sourceDecorators.forEach(decorator -> decorator.decorate(request, address, params));
return params.build();
}
@Override
public HttpRequestParams provideSinkParams(DataFlowStartMessage request) {
var params = HttpRequestParams.Builder.newInstance();
var address = HttpDataAddress.Builder.newInstance().copyFrom(request.getDestinationDataAddress()).build();
sinkDecorators.forEach(decorator -> decorator.decorate(request, address, params));
return params.build();
}

So indeed the extractMethod returns the method specified by the DestinationDataAddress.

Did I understood this correctly?

Thanks for fixing this!

@ndr-brt ndr-brt requested a review from efiege January 24, 2024 13:17
@ndr-brt ndr-brt merged commit 911a6f9 into eclipse-edc:main Jan 25, 2024
17 checks passed
@ndr-brt ndr-brt deleted the 3768-stop-checking-method-for-push-http-transfer branch January 25, 2024 08:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working dpf Feature related to the Data Plane Framework
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Assets Containing the proxyMethod=true Property can not be used with the ProviderPushTransfer
5 participants