LinkedSoftwareDependencies / Components.js

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

Invalid Predicate IRI #114

Closed angelaraya closed 1 year ago

angelaraya commented 1 year ago

Issue type:


Description:

I've created this class and generated the context files using componentsjs-generator (3.1.0). At runtime, componentsjs throws with the error below. Here is the config file.

As you can see, using, what I assume is a more precise path, for the other parameters I get no error but this is not ideal. I assume there is something wrong in the project configuration but I can't pin point exactly where. Any help is appreciated.


Environment:

ComponentsJS: 5.3.2 Node: 16.9.0

Crash log:

2023-01-31T22:05:58.035Z [Components.js] info: Initiating component discovery from /CODE/solid/sai-impl-service/packages/service
2023-01-31T22:05:58.214Z [Components.js] info: Discovered 166 component packages within 1422 packages
2023-01-31T22:05:58.215Z [Components.js] info: Initiating component loading
2023-01-31T22:06:00.479Z [Components.js] debug: Registered a module https://linkedsoftwaredependencies.org/bundles/npm/@comunica/config-query-sparql without components.
2023-01-31T22:06:00.500Z [Components.js] info: Registered 847 components
2023-01-31T22:06:00.501Z [Components.js] info: Loaded configs
/CODE/solid/sai-impl-service/node_modules/componentsjs/lib/rdf/RdfParser.js:85
        return new Error(`Error while parsing file "${path}": ${error.message}`);
               ^

Error: Error while parsing file "/CODE/solid/sai-impl-service/packages/service/config/redis-connection.json": Invalid predicate IRI: host
    at Function.addPathToError (/CODE/solid/sai-impl-service/node_modules/componentsjs/lib/rdf/RdfParser.js:85:16)
    at PassThrough.<anonymous> (/CODE/solid/sai-impl-service/node_modules/componentsjs/lib/rdf/RdfParser.js:58:38)
    at PassThrough.emit (node:events:525:35)
    at JsonLdParser.<anonymous> (/CODE/solid/sai-impl-service/node_modules/rdf-parse/lib/RdfParser.js:59:47)
    at JsonLdParser.emit (node:events:525:35)
    at ParsingContext.emitError (/CODE/solid/sai-impl-service/node_modules/jsonld-streaming-parser/lib/ParsingContext.js:232:21)
    at Util.predicateToTerm (/CODE/solid/sai-impl-service/node_modules/jsonld-streaming-parser/lib/Util.js:437:37)
    at EntryHandlerPredicate.handle (/CODE/solid/sai-impl-service/node_modules/jsonld-streaming-parser/lib/entryhandler/EntryHandlerPredicate.js:106:38)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async JsonLdParser.newOnValueJob (/CODE/solid/sai-impl-service/node_modules/jsonld-streaming-parser/lib/JsonLdParser.js:201:21)
github-actions[bot] commented 1 year ago

Thanks for reporting!

rubensworks commented 1 year ago

Are you sure that you've re-executed the build:components script?

Could you share the generated components/components.jsonld and components/context.jsonld files?

angelaraya commented 1 year ago

Yes, I've rebuilt the project several times, this is just from a fresh build:

dist/components/components.jsonld and dist/components/context.jsonld

rubensworks commented 1 year ago

I don't see any problems with this at first glance. Your host parameter is available in both of those files, so they should be recognised when using them in the config file using the proper context import.

Have you been able to use Components.js successfully in the past in this project? Or is it just this class that causes problems?

angelaraya commented 1 year ago

Yes, the problem surfaced with this class. In the main branch of the repo a working config has been there for a while.

On Thu, Feb 2, 2023, 02:59 Ruben Taelman @.***> wrote:

I don't see any problems with this at first glance. Your host parameter is available in both of those files, so they should be recognised when using them in the config file using the proper context import.

Have you been able to use Components.js successfully in the past in this project? Or is it just this class that causes problems?

— Reply to this email directly, view it on GitHub https://github.com/LinkedSoftwareDependencies/Components.js/issues/114#issuecomment-1413366615, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANV7ZWQQRHDJAZT57KBGAVTWVNZPTANCNFSM6AAAAAAUM7LGGU . You are receiving this because you authored the thread.Message ID: @.*** com>

rubensworks commented 1 year ago

Not sure what the problem could be then.

Perhaps you could try creating another empty class, and using that one in the config, and then step-by-step add elements from RedisConnectionInfo until it breaks?

angelaraya commented 1 year ago

I've went and made a minimal reproduction example. I've added a single class:

export class ConnectionInfo {
  constructor(
    public host: string,
  ) {
  }
}

And instantiated once, at the top of the main config file:

"@graph": [
    {
      "@id": "urn:ssv:ConnectionInfo",
      "@type": "ConnectionInfo",
      "host": "localhost"
    },

    {
      "@id": "urn:ssv:SessionManager",
      "@type": "SessionManager",
      "info": {
        "@id": "urn:ssv:ConnectionInfo"
      },
[...]

Context and components files get updated as expected, but at runtime I still get the invalid predicated IRI error. One thing to notice is that if I remove the usage from the SessionManager class then the error disappears, but I don't know the reason for this.

You can find this at the cjs-issue-141 branch.

angelaraya commented 1 year ago

I believe I've found the issue, in the config declaration "type": "SomeType" is of course not the same as "@type": "SomeType".

Perhaps a better error description, or just a warning when using "type" instead of "@type" would be an improvement.

rubensworks commented 1 year ago

Ah, of course, good catch :-)

Perhaps a better error description, or just a warning when using "type" instead of "@type" would be an improvement.

Warning is difficult, but an alias could definitely be added. Feel free to open an issue or PR!