Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

TypeError: Cannot read property 'children' of undefined #32

Closed
ssbarnea opened this issue Mar 20, 2022 · 2 comments
Closed

TypeError: Cannot read property 'children' of undefined #32

ssbarnea opened this issue Mar 20, 2022 · 2 comments

Comments

@ssbarnea
Copy link

Crash while opening rst files from https://github.com/ansible-community/ansible-lint project.

[2022-03-20 08:45:06.916] [exthost] [error] [trond-snekvik.simple-rst] provider FAILED
[2022-03-20 08:45:06.916] [exthost] [error] TypeError: Cannot read property 'children' of undefined
	at RstSectionProvider.provideDocumentSymbols (/Users/ssbarnea/.vscode/extensions/trond-snekvik.simple-rst-1.5.2/out/extension.js:52:41)
	at f.provideDocumentSymbols (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:85:91179)
	at /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:85:117502
	at be._withAdapter (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:85:116655)
	at be.$provideDocumentSymbols (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:85:117480)
	at n._doInvokeHandler (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:89:13812)
	at n._invokeHandler (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:89:13496)
	at n._receiveRequest (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:89:12107)
	at n._receiveOneMessage (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:89:10836)
	at /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:89:8945
	at d.invoke (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:58:145)
	at w.fire (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:58:1856)
	at c.fire (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:66:19017)
	at /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:104:34267
	at d.invoke (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:58:145)
	at w.fire (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:58:1856)
	at c.fire (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:66:19017)
	at s._receiveMessage (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:66:23598)
	at /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:66:21132
	at d.invoke (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:58:145)
	at w.fire (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:58:1856)
	at w.acceptChunk (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:66:15848)
	at /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:66:14978
	at Socket.P (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:104:13790)
	at Socket.emit (events.js:315:20)
	at addChunk (internal/streams/readable.js:309:12)
	at readableAddChunk (internal/streams/readable.js:284:9)
	at Socket.Readable.push (internal/streams/readable.js:223:10)
	at Pipe.onStreamRead (internal/stream_base_commons.js:188:23)

Reproduced with v1.5.2

@sgryjp
Copy link
Contributor

sgryjp commented Mar 19, 2023

Hi, I think I encountered the same issue. The extension fails if the conditions bellow met at the same time:

  • There are two or more top level headings
  • The first heading doesn’t have a child heading

Under the condition, (a) on finding the first heading the extension pushes it into a stack, (b) pops it on finding the second heading, then (c) tries to append the second heading to the children of the “last entry of the stack”… which should be the currently active parent heading. Here, because the stack became empty on step (b), getting the last entry of the stack fails and be evaluated as undefined. Thus, an exception occur by accessing the property children of the undefined.

@trond-snekvik
Copy link
Owner

Fixed by #36.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants