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

node-opcua will not instantiate a child variable when it has the same name as its parent objectType #1320

Closed
tetanw opened this issue Nov 16, 2023 · 2 comments
Labels
bug Fixed: requesting verification The bug has been resolved and is expecting extra validation by the community t

Comments

@tetanw
Copy link
Contributor

tetanw commented Nov 16, 2023

Current behavior / Describe the bug

If I create an objectType named Test which has a child variable named Test then the child variable will never be instantiated. Other child variables are instantiated because I added an extra one named Test2 that is indeed instantiated.

See:
image

Step by step instruction to reproduce

Steps to reproduce the behavior:

  1. Copy files from gist into a folder
  2. Copy the standard nodeset Opc.Ua.NodeSet2.xml into the folder as well
  3. npm install
  4. node server.js
  5. Open any OpcUa browser and see that child variable Test is not created.

Expected behavior

I expect the child variable to be created. It is not good practice to name the variable the same, but I do think this is allowed by the OpcUa specification.

Gist

gist: https://gist.github.com/tetanw/c1c2a92dbe77e20efebba90ad057a195

Context

  • ( ) my request is related to node-opcua acting as an OPCUA CLIENT

  • (x) my request is related to node-opcua acting as an OPCUA SERVER

  • ( ) I have installed node-opcua from source ( using git clone)

  • (x) I have installed node-opcua as a package ( using npm install )

  • ( ) I am using an application that uses node-opcua

    • ( ) node-red
    • ( ) other : please specify
  • Device: Lenovo Thinkstation P700

  • OS version:

    • (x) Windows : version : Windows 10 Enterprise, 21H2
    • ( ) Linux : version : ______
    • ( ) MacOs : version : ______
    • ( ) Raspbian: version : ______
    • ( ) Other : specify : ______
  • Description of the other OPCUA system I am trying to connect to: NA

  • node-opcua version: 2.115.0

  • Node: v18.16.0

@tetanw
Copy link
Contributor Author

tetanw commented Dec 12, 2023

Found the issue. The optional filter thinks it is already in while it isn't, because the references list contains a HasTypeDefinition reference with a matching browseName:

const alreadyIn = this.references.filter((r: UAReference) => {
const n = addressSpace.findNode(r.nodeId)!;
// istanbul ignore next
if (!n) {
warningLog(" cannot find node ", r.nodeId.toString());
return false;
}
return n.browseName!.name!.toString() === node.browseName!.name!.toString();
});
if (alreadyIn.length > 0) {
assert(alreadyIn.length === 1, "Duplication found ?");
// a child with the same browse name has already been install
// probably from a SuperClass, we should ignore this.
return false; // ignore
}

I think the solution is to not check all references, but, instead only check all Aggregates type references here:

tetanw added a commit to tetanw/node-opcua that referenced this issue Dec 12, 2023
erossignon pushed a commit that referenced this issue Feb 20, 2024
@erossignon
Copy link
Member

Fixed in node-opcua@2.121.0

@erossignon erossignon added bug Fixed: requesting verification The bug has been resolved and is expecting extra validation by the community t labels Feb 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Fixed: requesting verification The bug has been resolved and is expecting extra validation by the community t
Projects
None yet
Development

No branches or pull requests

2 participants