LinkedSoftwareDependencies / Components.js

🧩 A semantic dependency injection framework
https://componentsjs.readthedocs.io/
Other
41 stars 6 forks source link

Raw value references cannot be used as keys in key/value objects #115

Closed joachimvh closed 1 year ago

joachimvh commented 1 year ago

Issue type:


Description:

Assume you define a value somewhere using valueRaw:

{
  "@id": "urn:my:id",
  "valueRaw": "my-value"
}

and use it as a key somewhere

{
  "MyClass:_myMap_key": { "@id": "urn:my:id" },
  "MyClass:_myMap_value": "other value"
}

Components.js will throw the error found at https://github.com/LinkedSoftwareDependencies/Components.js/blob/078dedc48cd88e037c7b0da722fc4280d317b17a/lib/construction/argument/ArgumentConstructorHandlerHash.ts#L32C3-L34

Using it as a value seems to work fine.


Environment:

Windows, Node v16.13.1, Components.js v5.3.2

Crash log:

Could not create the server
Cause: Illegal non-literal key (urn:solid-server:default:value:accountCookieName as NamedNode) in fields entry
ErrorResourcesContext: Illegal non-literal key (urn:solid-server:default:value:accountCookieName as NamedNode) in fields entry
    at C:\projects\solid\community-server\node_modules\componentsjs\lib\construction\argument\ArgumentConstructorHandlerHash.js:21:23
    at Array.map (<anonymous>)
    at ArgumentConstructorHandlerHash.handle (C:\projects\solid\community-server\node_modules\componentsjs\lib\construction\argument\ArgumentConstructorHandlerHash.js:15:50)
    at ConfigConstructor.getArgumentValue (C:\projects\solid\community-server\node_modules\componentsjs\lib\construction\ConfigConstructor.js:48:32)
    at C:\projects\solid\community-server\node_modules\componentsjs\lib\construction\ConfigConstructor.js:66:41
    at Array.map (<anonymous>)
    at ConfigConstructor.createArguments (C:\projects\solid\community-server\node_modules\componentsjs\lib\construction\ConfigConstructor.js:66:18)
    at ConfigConstructor.createInstance (C:\projects\solid\community-server\node_modules\componentsjs\lib\construction\ConfigConstructor.js:78:33)
    at ConfigConstructorPool.instantiate (C:\projects\solid\community-server\node_modules\componentsjs\lib\construction\ConfigConstructorPool.js:56:71)
    at ArgumentConstructorHandlerReference.handle (C:\projects\solid\community-server\node_modules\componentsjs\lib\construction\argument\ArgumentConstructorHandlerReference.js:22:56)
github-actions[bot] commented 1 year ago

Thanks for reporting!

rubensworks commented 1 year ago

I'm surprised such value references even works with value. Is this a documented feature (I don't remember it being one)? It may just work by chance πŸ˜…

joachimvh commented 1 year ago

I found out about their existence in a random comment in a discussion πŸ˜„

rubensworks commented 1 year ago

Changing this to a feature request then :-)