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

More type errors #201

Closed
trieloff opened this issue Jan 14, 2020 · 3 comments
Closed

More type errors #201

trieloff opened this issue Jan 14, 2020 · 3 comments
Assignees

Comments

@trieloff
Copy link
Collaborator

@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.

Originally posted by @AndyOGo in #198 (comment)

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

@AndyOGo this one looks different, as it seems to fail in the processing of an inlineCode block in Markdown. Maybe you can isolate the error and share an example schema.

@AndyOGo
Copy link
Contributor

AndyOGo commented Jan 14, 2020

@trieloff Okay.
Turns out to be the type keyword as a properties key:

UPDATED:
Reproduction PR: https://github.com/axa-ch/cyclic-schemas-test/pull/2/files#diff-5e01bb7966faca5294691cb9422f5321

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "$id": "http://www.example.com/schemas/components/Button.json",
  "type": "object",
  "title": "Button",
  "description": "Renders a Button.",
  "additionalProperties": false,
  "properties": {
    "properties": {
      "type": "object",
      "title": "Properties",
      "description": "Properties of Button.",
      "additionalProperties": false,
      "properties": {
        "type": {
          "type": "string",
          "enum": [
            "button",
            "submit",
            "reset"
          ],
          "title": "Type",
          "description": "The type of the Button (not used for anchors)."
        }
      }
    }
  }
}

I think any key for object's type properties listing shouldn't have any side effect or special treatment 🤔

I added a try/catch block and a log at:
https://github.com/wooorm/longest-streak/blob/7abefd44375aa51e976e3939dbc7f7d965310ec8/index.js#L16

Which yields this log:

TypeError: Cannot convert object to primitive value
    at String (<anonymous>)
    at longestStreak (/Users/axawinterthur/dev/aletheia/node_modules/longest-streak/index.js:17: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)
{ type: 'string',
  enum: [ 'button', 'submit', 'reset' ],
  title: 'Type',
  description: 'The type of the Button (not used for anchors).',
  [Symbol(myslug)]: 'button-properties-properties-properties-type' }

@trieloff trieloff self-assigned this Jan 15, 2020
trieloff added a commit that referenced this issue Jan 16, 2020
trieloff added a commit that referenced this issue Jan 20, 2020
…cyclic-schemas-test#2

this uses the axa-ch/cyclic-schemas-test#2 branch for the integration tests, which then fail, as
expected

see #201
trieloff pushed a commit that referenced this issue Jan 20, 2020
## [4.0.9](v4.0.8...v4.0.9) (2020-01-20)

### Bug Fixes

* **markdown:** prevent unescaped objects in markdown AST ([87d709a](87d709a)), closes [#201](#201)
@trieloff
Copy link
Collaborator Author

🎉 This issue has been resolved in version 4.0.9 🎉

The release is available on:

Your semantic-release bot 📦🚀

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