Skip to content

ClassCastException when returning arrays from JS functions in OrientDB 3.2.x #10532

@riverlover

Description

@riverlover

OrientDB Version: 3.2.43
Previous Version (works): 3.0.37

Description:
In OrientDB 3.0.37, returning a JavaScript array from a custom JS function works as expected. In OrientDB 3.2.43, returning a JS array throws a ClassCastException.

Steps to Reproduce:

  1. Create a JS function in OrientDB:
// Convert to JS native array
var jsList = [];
for (var i = 0; i < 10; i++) {
    jsList.push(i);
}

return jsList;
  1. Execute the function in 3.0.37 → works fine:
[
  {
    "@type": "d",
    "@version": 0,
    "value": [
      0,1,2,3,4,5,6,7,8,9
    ]
  }
]
  1. Execute the same function in 3.2.43 → throws:
{
    "errors": [
        {
            "code": 500,
            "reason": 500,
            "content": "java.lang.ClassCastException: Cannot convert '0'(language: Java, type: java.lang.Integer)  using Value.asHostObject(): Value is not a host object. You can ensure that the value can be converted using Value.isHostObject()."
        }
    ]
}

Observations:

  • Returning Map/HashMap works fine in both versions.
  • Returning primitive values (e.g., String, Number) works fine.
  • Returning arrays (JavaScript array or Java ArrayList) fails in 3.2.43.

Expected Behavior:
JS arrays returned from custom functions should work consistently across versions, similar to how returning Map works.

Notes:

  • The issue seems related to changes in the JS engine or type conversion between OrientDB versions 3.0.x and 3.2.x.

Metadata

Metadata

Assignees

No one assigned

    Labels

    buglegacy not used anymore

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions