Skip to content

default value for -l and -s options seems to be wrong #22

@VladimirAlexiev

Description

@VladimirAlexiev

According to online help, the lint and safe options are turned off by default:

# jsonld canonize -h
Options:
  -l, --lint             show lint warnings [false]
  -s, --safe             enable safe mode [false]

I have a file with a couple of defects:

# cat input.jsonld
{
  "@context": {
    "@vocab": "http://schema.org/",
    "countries": "http://publication.europa.eu/resource/authority/country/"
  },
  "@graph": [
    {
      "@id": "countries:ITA"
    },
    {
      "@id": "http://people.example/Homer",
      "full_name": "Homer Simpson",
      "country": {
        "@id": "countries:ITA"
      }
    },
    {
      "@id": "http://people.example/Lisa",
      "full_name": "Lisa Simpson",
      "country": {
        "@id": "countries:ITA"
      }
    }
  ]
}

If I feed it to canonize, it complains about both "safe" and "lint", there's no way to disable those checks, and it produces no output:

# jsonld canonize input.jsonld
jsonld.ValidationError: Safe mode validation error.
    at safeEventHandler (C:\Users\Vladimir Alexiev\AppData\Roaming\npm\node_modules\jsonld-cli\node_modules\jsonld\lib\events.js:133:11)
    at _handle (C:\Users\Vladimir Alexiev\AppData\Roaming\npm\node_modules\jsonld-cli\node_modules\jsonld\lib\events.js:82:7)
    at api.handleEvent (C:\Users\Vladimir Alexiev\AppData\Roaming\npm\node_modules\jsonld-cli\node_modules\jsonld\lib\events.js:71:3)
    at _dropUnsafeObject (C:\Users\Vladimir Alexiev\AppData\Roaming\npm\node_modules\jsonld-cli\node_modules\jsonld\lib\expand.js:415:7)
    at Object.api.expand (C:\Users\Vladimir Alexiev\AppData\Roaming\npm\node_modules\jsonld-cli\node_modules\jsonld\lib\expand.js:381:12)
    at async Object.api.expand (C:\Users\Vladimir Alexiev\AppData\Roaming\npm\node_modules\jsonld-cli\node_modules\jsonld\lib\expand.js:125:15)
    at async _expandObject (C:\Users\Vladimir Alexiev\AppData\Roaming\npm\node_modules\jsonld-cli\node_modules\jsonld\lib\expand.js:920:25)
    at async api.expand (C:\Users\Vladimir Alexiev\AppData\Roaming\npm\node_modules\jsonld-cli\node_modules\jsonld\lib\expand.js:251:3)
    at async Function.jsonld.expand (C:\Users\Vladimir Alexiev\AppData\Roaming\npm\node_modules\jsonld-cli\node_modules\jsonld\lib\jsonld.js:321:18)
    at async Function.jsonld.toRDF (C:\Users\Vladimir Alexiev\AppData\Roaming\npm\node_modules\jsonld-cli\node_modules\jsonld\lib\jsonld.js:680:16)
Error: {
  name: 'jsonld.ValidationError',
  details: {
    event: {
      type: [ 'JsonLdEvent' ],
      code: 'object with only @id',
      level: 'warning',
      message: 'Dropping object with only @id.',
      details: {
        value: {
          '@id': 'http://publication.europa.eu/resource/authority/country/ITA'
        }
      }
    }
  }
}

The other modes (expand, flatten, format) don't issues such errors/warnings

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions