ballerina-platform / ballerina-lang

The Ballerina Programming Language

Home Page:https://ballerina.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug]: Shell error for http:Client

Shadow-Devil opened this issue · comments

Description

Constructing a http:Client in the shell results in an error on Windows.

Steps to Reproduce

run bal shell
then insert the following:

http:Client client1 = check new http:Client("");

Returns error:

| $configureInit exception at target: java.lang.NoSuchFieldError: $type$(ballerina&0047crypto&00582&0058PublicKey & readonly)

Affected Version(s)

2201.9.0

OS, DB, other environment details and versions

Windows 11

Related area

-> Shell

Related issue(s) (optional)

No response

Suggested label(s) (optional)

No response

Suggested assignee(s) (optional)

No response

Debug logs:

| Node identified as a IMPORT_DECLARATION snippet.
| Adding import: import ballerina/http;
| Node identified as a VARIABLE_DECLARATION snippet.
| Found variables: [client1]
| Implicit imports added: {client1=[http]}
| Found new variables: {client1=<any>  http:Client client1}
| Running $configurationMapper.$configureInit directly
| $configureInit exception at target: java.lang.NoSuchFieldError: $type$(ballerina&0047crypto&00582&0058PublicKey & readonly)

I'm getting this error on MacOS as well, I'm trying the graphql-service sample from the samples repo:

[2024-06-11 19:25:43,773] SEVERE {b7a.log.crash} - $type$(ballerina&0047crypto&00582&0058PublicKey & readonly) 
java.lang.NoSuchFieldError: $type$(ballerina&0047crypto&00582&0058PublicKey & readonly)
        at ballerina.http.2.constants.$_union_type_constants.createMembers$$unionType1170(Unknown Source)
        at ballerina.http.2.constants.$_union_type_constants.$populate$unionType117(Unknown Source)
        at ballerina.http.2.constants.$_union_type_constants.$populate_union_types1(Unknown Source)
        at ballerina.http.2.constants.$_union_type_constants.$populate_union_types(Unknown Source)
        at ballerina.http.2.types.$_types.$createTypeConstants(Unknown Source)
        at ballerina.http.2.types.$_types.$createTypes(Unknown Source)
        at ballerina.http.2.$_init.$currentModuleInit(http)
        at ballerina.http.2.$configurationMapper.$initAndPopulateConfigData(Unknown Source)
        at raulbojalil.graphql_api.0.$configurationMapper.$configureInit(Unknown Source)
        at raulbojalil.graphql_api.0.$_init.main(graphql_api)

We were unable to reproduce this issue in the shell. @raulbojalil Could you execute bal graph for your sample and share it? Also what is the sample you used to reproduce this?

This issue seems to be due to an incompatible change in a dependency. We are working on fixing this at the moment and we will update this issue as soon as the fix is done. We apologize for the inconvenience.

We were able to reproduce this issue with the following steps.

  1. Remove the HTTP 2.11.1 and JWT 2.12.0 balas and BIRs if already present locally.
  2. Create a project with a simple HTTP service, and build offline. This will create the Dependencies.toml file with JWT 2.11.0 and HTTP 2.11.0
  3. Now create a separate (similar) project, but build without the offline flag. This will result in the new versions of both modules (JWT 2.12.0 and HTTP 2.11.1) being pulled and the BIR being cached.
  4. Now go back to the first project,
    a. Do a bal clean to remove the target directory (to simulate patch version being bumped after 24 hours)
    b. Do a bal run. The JWT version will remain 2.11.0, but the HTTP version will be updated to 2.11.1 in the Dependencies.toml file. The program crashes at runtime since the HTTP 2.11.1 BIR referes to a JWT type that is not present in 2.11.0.

I was able to reproduce this on the shell also after following these steps.

We were unable to reproduce this issue in the shell. @raulbojalil Could you execute bal graph for your sample and share it? Also what is the sample you used to reproduce this?

I used this one: https://github.com/wso2/choreo-samples/blob/main/graphql-service/sample.bal

This is the output of bal graph

digraph "raulbojalil/graphql_api:0.1.0" {
        node [shape=record]
        "raulbojalil/graphql_api" [label="<0.1.0> raulbojalil/graphql_api:0.1.0"];
        "ballerinai/observe" [label="<0.0.0> ballerinai/observe:0.0.0"];
        "ballerina/graphql" [label="<1.13.0> ballerina/graphql:1.13.0"];
        "ballerina/websocket" [label="<2.11.0> ballerina/websocket:2.11.0"];
        "ballerina/uuid" [label="<1.8.0> ballerina/uuid:1.8.0"];
        "ballerina/http" [label="<2.11.1> ballerina/http:2.11.1"];
        "ballerina/oauth2" [label="<2.11.0> ballerina/oauth2:2.11.0"];
        "ballerina/url" [label="<2.4.0> ballerina/url:2.4.0"];
        "ballerina/mime" [label="<2.9.0> ballerina/mime:2.9.0"];
        "ballerina/jwt" [label="<2.11.0> ballerina/jwt:2.11.0"];
        "ballerina/file" [label="<1.9.0> ballerina/file:1.9.0"];
        "ballerina/os" [label="<1.8.0> ballerina/os:1.8.0"];
        "ballerina/cache" [label="<3.8.0> ballerina/cache:3.8.0"];
        "ballerina/task" [label="<2.5.0> ballerina/task:2.5.0"];
        "ballerina/constraint" [label="<1.5.0> ballerina/constraint:1.5.0"];
        "ballerina/auth" [label="<2.11.0> ballerina/auth:2.11.0"];
        "ballerina/log" [label="<2.9.0> ballerina/log:2.9.0"];
        "ballerina/observe" [label="<1.2.3> ballerina/observe:1.2.3"];
        "ballerina/io" [label="<1.6.0> ballerina/io:1.6.0"];
        "ballerina/crypto" [label="<2.7.2> ballerina/crypto:2.7.2"];
        "ballerina/time" [label="<2.4.0> ballerina/time:2.4.0"];

        // Edges
        "raulbojalil/graphql_api":"0.1.0" -> "ballerinai/observe":"0.0.0";
        "raulbojalil/graphql_api":"0.1.0" -> "ballerina/graphql":"1.13.0";
        "ballerinai/observe":"0.0.0" -> "ballerina/observe":"1.2.3";
        "ballerina/graphql":"1.13.0" -> "ballerina/task":"2.5.0";
        "ballerina/graphql":"1.13.0" -> "ballerina/file":"1.9.0";
        "ballerina/graphql":"1.13.0" -> "ballerina/auth":"2.11.0";
        "ballerina/graphql":"1.13.0" -> "ballerina/mime":"2.9.0";
        "ballerina/graphql":"1.13.0" -> "ballerina/websocket":"2.11.0";
        "ballerina/graphql":"1.13.0" -> "ballerina/io":"1.6.0";
        "ballerina/graphql":"1.13.0" -> "ballerina/time":"2.4.0";
        "ballerina/graphql":"1.13.0" -> "ballerina/log":"2.9.0";
        "ballerina/graphql":"1.13.0" -> "ballerina/jwt":"2.11.0";
        "ballerina/graphql":"1.13.0" -> "ballerina/oauth2":"2.11.0";
        "ballerina/graphql":"1.13.0" -> "ballerina/crypto":"2.7.2";
        "ballerina/graphql":"1.13.0" -> "ballerina/uuid":"1.8.0";
        "ballerina/graphql":"1.13.0" -> "ballerina/cache":"3.8.0";
        "ballerina/graphql":"1.13.0" -> "ballerina/observe":"1.2.3";
        "ballerina/graphql":"1.13.0" -> "ballerina/http":"2.11.1";
        "ballerina/websocket":"2.11.0" -> "ballerina/auth":"2.11.0";
        "ballerina/websocket":"2.11.0" -> "ballerina/io":"1.6.0";
        "ballerina/websocket":"2.11.0" -> "ballerina/time":"2.4.0";
        "ballerina/websocket":"2.11.0" -> "ballerina/constraint":"1.5.0";
        "ballerina/websocket":"2.11.0" -> "ballerina/log":"2.9.0";
        "ballerina/websocket":"2.11.0" -> "ballerina/jwt":"2.11.0";
        "ballerina/websocket":"2.11.0" -> "ballerina/oauth2":"2.11.0";
        "ballerina/websocket":"2.11.0" -> "ballerina/http":"2.11.1";
        "ballerina/uuid":"1.8.0" -> "ballerina/crypto":"2.7.2";
        "ballerina/uuid":"1.8.0" -> "ballerina/time":"2.4.0";
        "ballerina/http":"2.11.1" -> "ballerina/file":"1.9.0";
        "ballerina/http":"2.11.1" -> "ballerina/auth":"2.11.0";
        "ballerina/http":"2.11.1" -> "ballerina/mime":"2.9.0";
        "ballerina/http":"2.11.1" -> "ballerina/io":"1.6.0";
        "ballerina/http":"2.11.1" -> "ballerina/time":"2.4.0";
        "ballerina/http":"2.11.1" -> "ballerina/constraint":"1.5.0";
        "ballerina/http":"2.11.1" -> "ballerina/log":"2.9.0";
        "ballerina/http":"2.11.1" -> "ballerina/jwt":"2.11.0";
        "ballerina/http":"2.11.1" -> "ballerina/oauth2":"2.11.0";
        "ballerina/http":"2.11.1" -> "ballerina/crypto":"2.7.2";
        "ballerina/http":"2.11.1" -> "ballerina/cache":"3.8.0";
        "ballerina/http":"2.11.1" -> "ballerina/observe":"1.2.3";
        "ballerina/http":"2.11.1" -> "ballerina/url":"2.4.0";
        "ballerina/oauth2":"2.11.0" -> "ballerina/crypto":"2.7.2";
        "ballerina/oauth2":"2.11.0" -> "ballerina/time":"2.4.0";
        "ballerina/oauth2":"2.11.0" -> "ballerina/cache":"3.8.0";
        "ballerina/oauth2":"2.11.0" -> "ballerina/log":"2.9.0";
        "ballerina/oauth2":"2.11.0" -> "ballerina/url":"2.4.0";
        "ballerina/mime":"2.9.0" -> "ballerina/io":"1.6.0";
        "ballerina/jwt":"2.11.0" -> "ballerina/crypto":"2.7.2";
        "ballerina/jwt":"2.11.0" -> "ballerina/time":"2.4.0";
        "ballerina/jwt":"2.11.0" -> "ballerina/cache":"3.8.0";
        "ballerina/jwt":"2.11.0" -> "ballerina/log":"2.9.0";
        "ballerina/file":"1.9.0" -> "ballerina/os":"1.8.0";
        "ballerina/file":"1.9.0" -> "ballerina/io":"1.6.0";
        "ballerina/file":"1.9.0" -> "ballerina/time":"2.4.0";
        "ballerina/os":"1.8.0" -> "ballerina/io":"1.6.0";
        "ballerina/cache":"3.8.0" -> "ballerina/task":"2.5.0";
        "ballerina/cache":"3.8.0" -> "ballerina/time":"2.4.0";
        "ballerina/cache":"3.8.0" -> "ballerina/constraint":"1.5.0";
        "ballerina/task":"2.5.0" -> "ballerina/time":"2.4.0";
        "ballerina/auth":"2.11.0" -> "ballerina/crypto":"2.7.2";
        "ballerina/auth":"2.11.0" -> "ballerina/log":"2.9.0";
        "ballerina/log":"2.9.0" -> "ballerina/io":"1.6.0";
        "ballerina/log":"2.9.0" -> "ballerina/observe":"1.2.3";
        "ballerina/crypto":"2.7.2" -> "ballerina/time":"2.4.0";
}

All, we've released JWT 2.12.1 and HTTP 2.11.2 addressing this issue.

Please note that if the last build for a project with which you observed this issue happened within 24 hours you would have to do a bal clean first to have the patch versions be updated during the build. Additionally, you could also remove the Dependencies.toml file, but this is not mandatory.

Please do let us know if you are still facing this issue.

Closing this issue since it has now been addressed via releases of the JWT and HTTP modules.

Please feel free to reopen if you're still facing this issue.

This issue is NOT closed with a proper Reason/ label. Make sure to add proper reason label before closing. Please add or leave a comment with the proper reason label now.

      - Reason/EngineeringMistake - The issue occurred due to a mistake made in the past.
      - Reason/Regression - The issue has introduced a regression.
      - Reason/MultipleComponentInteraction - Issue occured due to interactions in multiple components.
      - Reason/Complex - Issue occurred due to complex scenario.
      - Reason/Invalid - Issue is invalid.
      - Reason/Other - None of the above cases.