LinkedSoftwareDependencies / Components.js

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

Unclear error message when a component is undefined #108

Closed constraintAutomaton closed 6 months ago

constraintAutomaton commented 1 year ago

Issue type:


Description:

In comunica I was in the process of including a new actor into the default engine more precisely in the rdf-resolve-quad-pattern configuration. When adding my actor into the file actors-rdfjs.json, my actor was not able to recognize its mediator and no error was provided to indicate that the problem came from actors-rdfjs.json. Meanwhile the inclusion into the file actors.json didn't cause any problem and I was able to integrate my actor.

This behavior probably should not happen and even if it should happen a clear error should be provided instead of not recognizing existing components.


Environment:

Components.js: 5.0.1 Node.js: v16.17.0 Operating system: Ubuntu 22.04.1 LTS

Crash log:

Error

2022-09-22T07:50:16.130Z [Components.js] error: Detected fatal error. Generated 'componentsjs-error-state.json' with more information.
ErrorResourcesContext: The value "urn:comunica:default:rdf-parse/mediators#parse" for parameter "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-rdf-resolve-quad-pattern-string-source/^1.0.0/components/ActorRdfResolveQuadPatternStringSource.jsonld#ActorRdfResolveQuadPatternStringSource_args_mediatorRdfParse" is not of required range type "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/core/^2.0.0/components/Mediator.jsonld#Mediator"

Beginning of the componentsjs-error-state file

{
    "cause": {
      "description": "value is not a subtype of \"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/core/^2.0.0/components/Mediator.jsonld#Mediator\"",
      "context": {
        "value": "urn:comunica:default:rdf-parse/mediators#parse",
        "type": {
          "@id": "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/core/^2.0.0/components/Mediator.jsonld#Mediator",
          "properties": {
            "https://linkedsoftwaredependencies.org/vocabularies/object-oriented#componentPath": [
              "\"Mediator\""
            ],
            "http://www.w3.org/2000/01/rdf-schema#subClassOf": [
              {
                "@id": "_:df_691_4"
              }
            ],
            "http://www.w3.org/2000/01/rdf-schema#comment": [
              "\"A mediator can mediate an action over a bus of actors.  It does the following: 1. Accepts an action in {@link Mediator#mediate}. 2. Sends the action to the bus to test its applicability on all actors. 3. It _mediates_ over these test results. 4. It selects the _best_ actor. 5. The action is run by the _best_ actor, and the result if returned.  The _mediates_ and _best_ parts are filled in by subclasses of this abstract Mediator class.\""
            ],
github-actions[bot] commented 1 year ago

Thanks for reporting!

rubensworks commented 1 year ago

So the error message here is very unclear when a component is used as param value, but this component is not defined yet.

We should make the error message clearer so that if 1) the param value is not a literal, and 2) the param value has no @type, then the error message should indicate that the given component (by @id) is undefined, and is missing an instantiation.

constraintAutomaton commented 1 year ago

So the error message here is very unclear when a component is used as param value, but this component is not defined yet.

We should make the error message clearer so that if 1) the param value is not a literal, and 2) the param value has no @type, then the error message should indicate that the given component (by @id) is undefined, and is missing an instantiation.

The mediator was defined it's the new actor that was in the process of definition. So I think the error was plain wrong, since erasing the actor from the actors-rdfjs.json file solve the error which has nothing to do with the existence of the mediator component.

rubensworks commented 1 year ago

The mediator was defined it's the new actor that was in the process of definition. So I think the error was plain wrong, since erasing the actor from the actors-rdfjs.json file solve the error which has nothing to do with the existence of the mediator component.

Yes, it was defined in that file, but the file was not being loaded in your case, which is why the mediator ended up not being defined for Components.js.

constraintAutomaton commented 1 year ago

The mediator was defined it's the new actor that was in the process of definition. So I think the error was plain wrong, since erasing the actor from the actors-rdfjs.json file solve the error which has nothing to do with the existence of the mediator component.

Yes, it was defined in that file, but the file was not being loaded in your case, which is why the mediator ended up not being defined for Components.js.

Maybe it's because I don't understand well components.js but I feel like this error should not had happen in the first place, because I don't think the import of component inside comunica should have an influence into their internal liking to other components. so the problem, in my opinion, is less the clarity of the error message but more on the linking of components.

rubensworks commented 1 year ago

Related to this: errors such as Invalid predicate IRI: mediatorDereferenceRdf may indicate incorrect component @type's.