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

UnhandledPromiseRejectionWarning: TypeError: Cannot convert object to primitive value #198

Closed
AndyOGo opened this issue Jan 14, 2020 · 5 comments

Comments

@AndyOGo
Copy link
Contributor

AndyOGo commented Jan 14, 2020

What did you do

Running as NPM script:
jsonschema2md -o docs/ -x docs/ -d schemas/ -e json

What did you expect to happen

No warnings of unhandled promise rejections.

What happened

Note: I reference unloaded JSON schemas of another project.

(node:23354) UnhandledPromiseRejectionWarning: TypeError: Cannot convert object to primitive value
    at makeconstraintssection (/Users/axawinterthur/dev/aletheia/node_modules/@adobe/jsonschema2md/lib/markdownBuilder.js:590:33)
    at Object.entries.map (/Users/axawinterthur/dev/aletheia/node_modules/@adobe/jsonschema2md/lib/markdownBuilder.js:715:14)
    at Array.map (<anonymous>)
    at makeproplist (/Users/axawinterthur/dev/aletheia/node_modules/@adobe/jsonschema2md/lib/markdownBuilder.js:705:54)
    at makeproperties (/Users/axawinterthur/dev/aletheia/node_modules/@adobe/jsonschema2md/lib/markdownBuilder.js:819:12)
    at foldl (/Users/axawinterthur/dev/aletheia/node_modules/@adobe/jsonschema2md/lib/markdownBuilder.js:843:10)
    at each (/Users/axawinterthur/dev/aletheia/node_modules/ferrum/src/sequence.js:984:12)
    at curry (/Users/axawinterthur/dev/aletheia/node_modules/ferrum/src/sequence.js:582:5)
    at each [CURRY] (/Users/axawinterthur/dev/aletheia/node_modules/ferrum/src/functional.js:169:12)
    at curry (/Users/axawinterthur/dev/aletheia/node_modules/ferrum/src/sequence.js:983:3)
(node:23354) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:23354) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

What's your environment

  • Operating System: macOS Catalina 10.15.2 (19C57)
  • node.js version: v10.15.0

Do you have example files:

Sorry, not publicly available for this.

I have the full log only:

> jsonschema2md -o docs/ -x docs/ -d schemas/ -e json

loading 53 schemas
cannot resolve http://jsonlogic.com/schemas/json-logic.json
cannot resolve http://jsonlogic.com/schemas/json-logic.json
writing schemas
writing schemas to .../docs
writing README
building readme
writing documentation
generating markdown
(node:23354) UnhandledPromiseRejectionWarning: TypeError: Cannot convert object to primitive value
    at makeconstraintssection (.../node_modules/@adobe/jsonschema2md/lib/markdownBuilder.js:590:33)
    at Object.entries.map (.../node_modules/@adobe/jsonschema2md/lib/markdownBuilder.js:715:14)
    at Array.map (<anonymous>)
    at makeproplist (.../node_modules/@adobe/jsonschema2md/lib/markdownBuilder.js:705:54)
    at makeproperties (.../node_modules/@adobe/jsonschema2md/lib/markdownBuilder.js:819:12)
    at foldl (.../node_modules/@adobe/jsonschema2md/lib/markdownBuilder.js:843:10)
    at each (.../node_modules/ferrum/src/sequence.js:984:12)
    at curry (.../node_modules/ferrum/src/sequence.js:582:5)
    at each [CURRY] (.../node_modules/ferrum/src/functional.js:169:12)
    at curry (.../node_modules/ferrum/src/sequence.js:983:3)
(node:23354) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:23354) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
.../docs/README.md created
@trieloff
Copy link
Collaborator

Do you have a schema where format is not a string?

@trieloff trieloff added the bug label Jan 14, 2020
@AndyOGo
Copy link
Contributor Author

AndyOGo commented Jan 14, 2020

Do you mean it's colliding with type string format validator?

I have an object type listing a format property, like:

{
      "type": "object",
      "title": "Properties",
      "description": "Properties of Datepicker.",

      "additionalProperties": false,
      "properties": {
        "format": {
          "type": "string",
          "title": "Format",
          "description": "Formatting used to display the date."
        },
        "value": {
          "type": "string",
          "title": "Value",
          "description": "Date to be displayed."
        }
      }
}

@trieloff
Copy link
Collaborator

Yes, that's exactly what's happening. I can fix this.

trieloff added a commit that referenced this issue Jan 14, 2020
@trieloff trieloff mentioned this issue Jan 14, 2020
trieloff pushed a commit that referenced this issue Jan 14, 2020
## [4.0.7](v4.0.6...v4.0.7) (2020-01-14)

### Bug Fixes

* **markdown:** increase robustness when using format as a property name ([cda0bec](cda0bec)), closes [#198](#198)
@trieloff
Copy link
Collaborator

🎉 This issue has been resolved in version 4.0.7 🎉

The release is available on:

Your semantic-release bot 📦🚀

@AndyOGo
Copy link
Contributor Author

AndyOGo commented Jan 14, 2020

@trieloff Thanks again for your quick help.

I have more output now, though another unhandled promise rejection.
We use other keywords as keys too, e.g. object type properties or array type items keywords, but those are all not primitives... 🤔

(node:26127) UnhandledPromiseRejectionWarning: TypeError: Cannot convert object to primitive value
    at String (<anonymous>)
    at longestStreak (/Users/axawinterthur/dev/aletheia/node_modules/longest-streak/index.js:16:11)
    at Of.inlineCode (/Users/axawinterthur/dev/aletheia/node_modules/remark-stringify/lib/visitors/inline-code.js:30:39)
    at Of.one [as visit] (/Users/axawinterthur/dev/aletheia/node_modules/remark-stringify/lib/macro/one.js:19:30)
    at Of.all (/Users/axawinterthur/dev/aletheia/node_modules/remark-stringify/lib/macro/all.js:14:27)
    at Of.tableCell (/Users/axawinterthur/dev/aletheia/node_modules/remark-stringify/lib/visitors/table-cell.js:8:15)
    at Of.one [as visit] (/Users/axawinterthur/dev/aletheia/node_modules/remark-stringify/lib/macro/one.js:19:30)
    at Of.all (/Users/axawinterthur/dev/aletheia/node_modules/remark-stringify/lib/macro/all.js:14:27)
    at Of.table (/Users/axawinterthur/dev/aletheia/node_modules/remark-stringify/lib/visitors/table.js:44:26)
    at Of.one [as visit] (/Users/axawinterthur/dev/aletheia/node_modules/remark-stringify/lib/macro/one.js:19:30)
(node:26127) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:26127) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants