Skip to content
New issue

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

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

Already on GitHub? # to your account

Custom xml subtypes gives "Unexpected error found due to typedesc and value mismatch." error #3113

Closed
chamil321 opened this issue Jul 14, 2022 · 4 comments · Fixed by ballerina-platform/module-ballerina-constraint#5
Assignees
Labels
module/constraint Reason/EngineeringMistake The issue occurred due to a mistake made in the past. Type/Bug

Comments

@chamil321
Copy link
Contributor

Description:

import ballerina/constraint;
import ballerina/test;
import ballerina/io;

type newXmlElement xml:Element;

@test:Config {}
public function thistest() {
    xml:Element payload = xml `<placeOrder><order-status>PLACED</order-status><order-id>ORD-1234</order-id></placeOrder>`;

    anydata|error validPayload = constraint:validate(payload, newXmlElement);
    if validPayload is error {
        io:println(validPayload.toString());
        test:assertFail(msg = "Found unexpected output type");
    } else {
        io:println(payload);
    }
}
@ldclakmal
Copy link
Member

@chamil321 I couldn't reproduce it. Shall we try again with the latest timestamp 1.0.0-20220714-093900-1688b84?

@chamil321
Copy link
Contributor Author

Checked with mentioned timestamp still getting the error

error Error ("Unexpected error found due to typedesc and value mismatch.")

                [fail] thistest:

                    Found unexpected output type

                        at ballerina.test.0:createBallerinaError(assert.bal:43)
                        ballerina.test.0:assertFail(assert.bal:235)
                        ballerina.http_tests$test.2.tests.service_dispatching_data_binding_anydata_test:thistest(tests/service_dispatching_data_binding_anydata_test.bal:14)


                0 passing
                1 failing
                0 skipped

@chamil321
Copy link
Contributor Author

Debugged the constraint package and found the issue

java.lang.ClassCastException: class io.ballerina.runtime.internal.types.BXmlType cannot be cast to class io.ballerina.runtime.api.types.AnnotatableType (io.ballerina.runtime.internal.types.BXmlType and io.ballerina.runtime.api.types.AnnotatableType are in unnamed module of loader 'app')

validate(value, (AnnotatableType) referredType);

@github-actions
Copy link

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.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
module/constraint Reason/EngineeringMistake The issue occurred due to a mistake made in the past. Type/Bug
Projects
Archived in project
2 participants