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

library crashes when invalid json schema #67

Closed
rmelian opened this issue Sep 13, 2019 · 2 comments
Closed

library crashes when invalid json schema #67

rmelian opened this issue Sep 13, 2019 · 2 comments
Labels
area/library Related to all activities around Library package bug Something isn't working

Comments

@rmelian
Copy link
Contributor

rmelian commented Sep 13, 2019

Description

when writing a document that is not valid the library crashes

Expected result
should not crash. should show an error indicating what's invalid or ignore the error

Actual result
image

Steps to reproduce

write the following example

asyncapi: '2.0.0'
id: 'urn:myapi'
info:
  title: My API
  version: '1.0.0'
channels:
  mychannel:
    publish:
      message:
        $ref: '#/components/messages/testMessage'

components:
  messages:
    testMessage:
      payload:
        $ref: '#/components/schemas/testSchema'
  schemas:
    testSchema:
      type: object
      properties:
        name:
          type: string
    order:
      type: object
      properties:
        name:
          type: string
    activity:
      type: o

the Activity type is invalid.

Troubleshooting

This is the validatedSchema returned from AsyncApi.tsx

const { validatedSchema, error } = this.state;

image

Error from Chrome console

Schema.js:47 Uncaught TypeError: Cannot create property 'description' on string 'o'
    at SchemaComponent (Schema.js:47)
    at renderWithHooks (react-dom.development.js:15821)
    at updateFunctionComponent (react-dom.development.js:17705)
    at beginWork$1 (react-dom.development.js:19371)
    at HTMLUnknownElement.callCallback (react-dom.development.js:363)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:412)
    at invokeGuardedCallback (react-dom.development.js:466)
    at beginWork$$1 (react-dom.development.js:24570)
    at performUnitOfWork (react-dom.development.js:23502)
    at workLoopSync (react-dom.development.js:23480)
    at renderRoot (react-dom.development.js:23155)
    at runRootCallback (react-dom.development.js:22809)
    at react-dom.development.js:11886
    at unstable_runWithPriority (scheduler.development.js:674)
    at runWithPriority$2 (react-dom.development.js:11834)
    at flushSyncCallbackQueueImpl (react-dom.development.js:11881)
    at flushSyncCallbackQueue (react-dom.development.js:11869)
    at scheduleUpdateOnFiber (react-dom.development.js:22667)
    at Object.enqueueSetState (react-dom.development.js:13710)
    at AsyncApiComponent.push../node_modules/react/cjs/react.development.js.Component.setState (react.development.js:324)
    at AsyncApiComponent.<anonymous> (AsyncApi.js:322)
    at step (AsyncApi.js:160)
    at Object.next (AsyncApi.js:91)
    at fulfilled (AsyncApi.js:43)
SchemaComponent @ Schema.js:47
renderWithHooks @ react-dom.development.js:15821
updateFunctionComponent @ react-dom.development.js:17705
beginWork$1 @ react-dom.development.js:19371
callCallback @ react-dom.development.js:363
invokeGuardedCallbackDev @ react-dom.development.js:412
invokeGuardedCallback @ react-dom.development.js:466
beginWork$$1 @ react-dom.development.js:24570
performUnitOfWork @ react-dom.development.js:23502
workLoopSync @ react-dom.development.js:23480
renderRoot @ react-dom.development.js:23155
runRootCallback @ react-dom.development.js:22809
(anonymous) @ react-dom.development.js:11886
unstable_runWithPriority @ scheduler.development.js:674
runWithPriority$2 @ react-dom.development.js:11834
flushSyncCallbackQueueImpl @ react-dom.development.js:11881
flushSyncCallbackQueue @ react-dom.development.js:11869
scheduleUpdateOnFiber @ react-dom.development.js:22667
enqueueSetState @ react-dom.development.js:13710
push../node_modules/react/cjs/react.development.js.Component.setState @ react.development.js:324
(anonymous) @ AsyncApi.js:322
step @ AsyncApi.js:160
(anonymous) @ AsyncApi.js:91
fulfilled @ AsyncApi.js:43
Promise.then (async)
step @ AsyncApi.js:60
(anonymous) @ AsyncApi.js:63
push.../../../dev/asyncapi/asyncapi-react/library/lib/containers/AsyncApi/AsyncApi.js.__awaiter @ AsyncApi.js:40
AsyncApiComponent.parseSchema @ AsyncApi.js:301
(anonymous) @ AsyncApi.js:228
step @ AsyncApi.js:160
(anonymous) @ AsyncApi.js:91
(anonymous) @ AsyncApi.js:63
push.../../../dev/asyncapi/asyncapi-react/library/lib/containers/AsyncApi/AsyncApi.js.__awaiter @ AsyncApi.js:40
AsyncApiComponent.componentDidUpdate @ AsyncApi.js:222
commitLifeCycles @ react-dom.development.js:21157
commitLayoutEffects @ react-dom.development.js:24138
callCallback @ react-dom.development.js:363
invokeGuardedCallbackDev @ react-dom.development.js:412
invokeGuardedCallback @ react-dom.development.js:466
commitRootImpl @ react-dom.development.js:23903
unstable_runWithPriority @ scheduler.development.js:674
runWithPriority$2 @ react-dom.development.js:11834
commitRoot @ react-dom.development.js:23723
runRootCallback @ react-dom.development.js:22809
(anonymous) @ react-dom.development.js:11886
unstable_runWithPriority @ scheduler.development.js:674
runWithPriority$2 @ react-dom.development.js:11834
flushSyncCallbackQueueImpl @ react-dom.development.js:11881
flushSyncCallbackQueue @ react-dom.development.js:11869
scheduleUpdateOnFiber @ react-dom.development.js:22667
dispatchAction @ react-dom.development.js:16542
updateSchema @ EditorPage.js:60
CodeEditorComponent.onChangeValue @ CodeEditor.tsx:48
(anonymous) @ index.js:695
(anonymous) @ codemirror.js:3168
fireCallbacksForOps @ codemirror.js:3107
finishOperation @ codemirror.js:3130
endOperation @ codemirror.js:5697
runInOp @ codemirror.js:5897
TextareaInput.poll @ codemirror.js:14182
(anonymous) @ codemirror.js:13899
Show 31 more frames
index.js:1375 The above error occurred in the <SchemaComponent> component:
    in SchemaComponent (created by SchemasComponent)
    in li (created by SchemasComponent)
    in ul (created by SchemasComponent)
    in div (created by Toggle)
    in div (created by Toggle)
    in Toggle (created by SchemasComponent)
    in section (created by SchemasComponent)
    in SchemasComponent (created by AsyncApiComponent)
    in section (created by AsyncApiComponent)
    in main (created by AsyncApiComponent)
    in useExpandedState.Provider (created by AsyncApiComponent)
    in AsyncApiComponent (at EditorPage.js:107)
    in div (created by Context.Consumer)
    in StyledComponent (created by styled.div)
    in styled.div (at EditorPage.js:106)
    in div (created by Context.Consumer)
    in StyledComponent (created by styled.div)
    in styled.div (at EditorPage.js:78)
    in div (created by Context.Consumer)
    in StyledComponent (created by styled.div)
    in styled.div (at EditorPage.js:76)
    in main (at TopMenuTemplate.js:24)
    in div (at TopMenuTemplate.js:22)
    in TopMenuTemplate (at EditorPage.js:75)
    in ApiEditor (at EditorPage.js:123)
    in Unknown (at EditorPage.js:140)
    in EditorPage (at App.js:54)
    in Route (at App.js:54)
    in Switch (at App.js:49)
    in Router (created by HashRouter)
    in HashRouter (at App.js:48)
    in MyApp (created by class_1)
    in class_1 (at src/index.js:13)
    in Router (created by BrowserRouter)
    in BrowserRouter (at src/index.js:12)

Consider adding an error boundary to your tree to customize error handling behavior.
Visit https://fb.me/react-error-boundaries to learn more about error boundaries.
console.<computed> @ index.js:1375
r @ backend.js:1
logCapturedError @ react-dom.development.js:20888
logError @ react-dom.development.js:20924
update.callback @ react-dom.development.js:22134
callCallback @ react-dom.development.js:13541
commitUpdateEffects @ react-dom.development.js:13581
commitUpdateQueue @ react-dom.development.js:13571
commitLifeCycles @ react-dom.development.js:21199
commitLayoutEffects @ react-dom.development.js:24138
callCallback @ react-dom.development.js:363
invokeGuardedCallbackDev @ react-dom.development.js:412
invokeGuardedCallback @ react-dom.development.js:466
commitRootImpl @ react-dom.development.js:23903
unstable_runWithPriority @ scheduler.development.js:674
runWithPriority$2 @ react-dom.development.js:11834
commitRoot @ react-dom.development.js:23723
runRootCallback @ react-dom.development.js:22809
(anonymous) @ react-dom.development.js:11886
unstable_runWithPriority @ scheduler.development.js:674
runWithPriority$2 @ react-dom.development.js:11834
flushSyncCallbackQueueImpl @ react-dom.development.js:11881
flushSyncCallbackQueue @ react-dom.development.js:11869
scheduleUpdateOnFiber @ react-dom.development.js:22667
enqueueSetState @ react-dom.development.js:13710
push../node_modules/react/cjs/react.development.js.Component.setState @ react.development.js:324
(anonymous) @ AsyncApi.js:322
step @ AsyncApi.js:160
(anonymous) @ AsyncApi.js:91
fulfilled @ AsyncApi.js:43
Promise.then (async)
step @ AsyncApi.js:60
(anonymous) @ AsyncApi.js:63
push.../../../dev/asyncapi/asyncapi-react/library/lib/containers/AsyncApi/AsyncApi.js.__awaiter @ AsyncApi.js:40
AsyncApiComponent.parseSchema @ AsyncApi.js:301
(anonymous) @ AsyncApi.js:228
step @ AsyncApi.js:160
(anonymous) @ AsyncApi.js:91
(anonymous) @ AsyncApi.js:63
push.../../../dev/asyncapi/asyncapi-react/library/lib/containers/AsyncApi/AsyncApi.js.__awaiter @ AsyncApi.js:40
AsyncApiComponent.componentDidUpdate @ AsyncApi.js:222
commitLifeCycles @ react-dom.development.js:21157
commitLayoutEffects @ react-dom.development.js:24138
callCallback @ react-dom.development.js:363
invokeGuardedCallbackDev @ react-dom.development.js:412
invokeGuardedCallback @ react-dom.development.js:466
commitRootImpl @ react-dom.development.js:23903
unstable_runWithPriority @ scheduler.development.js:674
runWithPriority$2 @ react-dom.development.js:11834
commitRoot @ react-dom.development.js:23723
runRootCallback @ react-dom.development.js:22809
(anonymous) @ react-dom.development.js:11886
unstable_runWithPriority @ scheduler.development.js:674
runWithPriority$2 @ react-dom.development.js:11834
flushSyncCallbackQueueImpl @ react-dom.development.js:11881
flushSyncCallbackQueue @ react-dom.development.js:11869
scheduleUpdateOnFiber @ react-dom.development.js:22667
dispatchAction @ react-dom.development.js:16542
updateSchema @ EditorPage.js:60
CodeEditorComponent.onChangeValue @ CodeEditor.tsx:48
(anonymous) @ index.js:695
(anonymous) @ codemirror.js:3168
fireCallbacksForOps @ codemirror.js:3107
finishOperation @ codemirror.js:3130
endOperation @ codemirror.js:5697
runInOp @ codemirror.js:5897
TextareaInput.poll @ codemirror.js:14182
(anonymous) @ codemirror.js:13899
Show 37 more frames
Schema.js:47 Uncaught (in promise) TypeError: Cannot create property 'description' on string 'o'
    at SchemaComponent (Schema.js:47)
    at renderWithHooks (react-dom.development.js:15821)
    at updateFunctionComponent (react-dom.development.js:17705)
    at beginWork$1 (react-dom.development.js:19371)
    at HTMLUnknownElement.callCallback (react-dom.development.js:363)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:412)
    at invokeGuardedCallback (react-dom.development.js:466)
    at beginWork$$1 (react-dom.development.js:24570)
    at performUnitOfWork (react-dom.development.js:23502)
    at workLoopSync (react-dom.development.js:23480)
    at renderRoot (react-dom.development.js:23155)
    at runRootCallback (react-dom.development.js:22809)
    at react-dom.development.js:11886
    at unstable_runWithPriority (scheduler.development.js:674)
    at runWithPriority$2 (react-dom.development.js:11834)
    at flushSyncCallbackQueueImpl (react-dom.development.js:11881)
    at flushSyncCallbackQueue (react-dom.development.js:11869)
    at scheduleUpdateOnFiber (react-dom.development.js:22667)
    at Object.enqueueSetState (react-dom.development.js:13710)
    at AsyncApiComponent.push../node_modules/react/cjs/react.development.js.Component.setState (react.development.js:324)
    at AsyncApiComponent.<anonymous> (AsyncApi.js:322)
    at step (AsyncApi.js:160)
    at Object.next (AsyncApi.js:91)
    at fulfilled (AsyncApi.js:43)
@rmelian
Copy link
Contributor Author

rmelian commented Sep 13, 2019

this issue will potentially happen at any level in an AsyncAPI document

@magicmatatjahu magicmatatjahu added area/library Related to all activities around Library package bug Something isn't working labels Sep 16, 2019
@derberg
Copy link
Member

derberg commented Sep 25, 2019

Fixed with #68
This week new version of the package will be released

@derberg derberg closed this as completed Sep 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/library Related to all activities around Library package bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants