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

ERROR TypeError: Cannot read property 'startLineNumber' of null when editing the preferences #7125

Closed
kittaakos opened this issue Feb 11, 2020 · 12 comments · Fixed by #7110
Closed
Assignees
Labels
bug bugs found in the application preferences issues related to preferences

Comments

@kittaakos
Copy link
Contributor

Description

I see errors in the log when editing the user preferences file manually in the preference widget's editor:

root ERROR TypeError: Cannot read property 'startLineNumber' of null
    at TextModel.validateRange (file:///Users/akos.kitta/git/theia/examples/electron/lib/vs/editor/editor.main.js:65306:55)
    at TextModel._applyEdits (file:///Users/akos.kitta/git/theia/examples/electron/lib/vs/editor/editor.main.js:65513:47)
    at TextModel.applyEdits (file:///Users/akos.kitta/git/theia/examples/electron/lib/vs/editor/editor.main.js:65504:29)
    at MonacoEditorModel.push.../../packages/monaco/lib/browser/monaco-editor-model.js.MonacoEditorModel.applyEdits (file:///Users/akos.kitta/git/theia/examples/electron/lib/31.bundle.js:1308:31)
    at MonacoEditorModel.<anonymous> (file:///Users/akos.kitta/git/theia/examples/electron/lib/31.bundle.js:1399:50)
    at step (file:///Users/akos.kitta/git/theia/examples/electron/lib/31.bundle.js:919:23)
    at Object.next (file:///Users/akos.kitta/git/theia/examples/electron/lib/31.bundle.js:900:53)
    at fulfilled (file:///Users/akos.kitta/git/theia/examples/electron/lib/31.bundle.js:891:58)
root ERROR TypeError: Cannot read property 'startLineNumber' of null
    at TextModel.validateRange (file:///Users/akos.kitta/git/theia/examples/electron/lib/vs/editor/editor.main.js:65306:55)
    at TextModel._applyEdits (file:///Users/akos.kitta/git/theia/examples/electron/lib/vs/editor/editor.main.js:65513:47)
    at TextModel.applyEdits (file:///Users/akos.kitta/git/theia/examples/electron/lib/vs/editor/editor.main.js:65504:29)
    at MonacoEditorModel.push.../../packages/monaco/lib/browser/monaco-editor-model.js.MonacoEditorModel.applyEdits (file:///Users/akos.kitta/git/theia/examples/electron/lib/31.bundle.js:1308:31)
    at MonacoEditorModel.<anonymous> (file:///Users/akos.kitta/git/theia/examples/electron/lib/31.bundle.js:1399:50)
    at step (file:///Users/akos.kitta/git/theia/examples/electron/lib/31.bundle.js:919:23)
    at Object.next (file:///Users/akos.kitta/git/theia/examples/electron/lib/31.bundle.js:900:53)
    at fulfilled (file:///Users/akos.kitta/git/theia/examples/electron/lib/31.bundle.js:891:58)
root ERROR TypeError: Cannot read property 'startLineNumber' of null
    at TextModel.validateRange (file:///Users/akos.kitta/git/theia/examples/electron/lib/vs/editor/editor.main.js:65306:55)
    at TextModel._applyEdits (file:///Users/akos.kitta/git/theia/examples/electron/lib/vs/editor/editor.main.js:65513:47)
    at TextModel.applyEdits (file:///Users/akos.kitta/git/theia/examples/electron/lib/vs/editor/editor.main.js:65504:29)
    at MonacoEditorModel.push.../../packages/monaco/lib/browser/monaco-editor-model.js.MonacoEditorModel.applyEdits (file:///Users/akos.kitta/git/theia/examples/electron/lib/31.bundle.js:1308:31)
    at MonacoEditorModel.<anonymous> (file:///Users/akos.kitta/git/theia/examples/electron/lib/31.bundle.js:1399:50)
    at step (file:///Users/akos.kitta/git/theia/examples/electron/lib/31.bundle.js:919:23)
    at Object.next (file:///Users/akos.kitta/git/theia/examples/electron/lib/31.bundle.js:900:53)
    at fulfilled (file:///Users/akos.kitta/git/theia/examples/electron/lib/31.bundle.js:891:58)

The broken preferences file:

{
    "workbench.iconTheme": "theia-file-icons",
    "workbench.colorTheme": "Visual Studio Dark",
    "yaml.schemas": {
        "kubernetes: "a.yaml"
    }
}

Note: auto-save was on.

Reproduction Steps

OS and Theia version:

Diagnostics:

@kittaakos kittaakos added the bug bugs found in the application label Feb 11, 2020
@akosyakov akosyakov added the preferences issues related to preferences label Feb 11, 2020
@akosyakov
Copy link
Member

I think i fixed it in #7110. Could you try? The issue was that vscode extensions can provide edits with range as null indicating that the full range should be covered. We did not respect it and passed null as range to Monaco.

@kittaakos
Copy link
Contributor Author

Could you try?

Sure.

@kittaakos
Copy link
Contributor Author

Could you try?

If I have auto-save on, I can see the following error in the browser console. I got this when editing the workspace preferences:

root ERROR Failed to update the value of 'editor.autoSave' in 'file:///workspace/theia/.theia/settings.json'. Error: Can not add index to parent of type property
    at Module.setProperty (https://3000-a6d802f0-bdbd-43d4-9a4f-bbf647e8a32f.ws-eu01.gitpod.io/3.bundle.js:150:15)
    at Module.modify (https://3000-a6d802f0-bdbd-43d4-9a4f-bbf647e8a32f.ws-eu01.gitpod.io/3.bundle.js:1575:66)
    at FolderPreferenceProvider.<anonymous> (https://3000-a6d802f0-bdbd-43d4-9a4f-bbf647e8a32f.ws-eu01.gitpod.io/39.bundle.js:224:64)
    at step (https://3000-a6d802f0-bdbd-43d4-9a4f-bbf647e8a32f.ws-eu01.gitpod.io/39.bundle.js:79:23)
    at Object.next (https://3000-a6d802f0-bdbd-43d4-9a4f-bbf647e8a32f.ws-eu01.gitpod.io/39.bundle.js:60:53)
    at fulfilled (https://3000-a6d802f0-bdbd-43d4-9a4f-bbf647e8a32f.ws-eu01.gitpod.io/39.bundle.js:51:58)

If I have auto-save off, I can see this when editing the user preferences:

1:25:52.243 logger-protocol.ts:112 root ERROR onWillSave listeners should provide edits, not directly alter the document.
log @ logger-protocol.ts:112
(anonymous) @ logger-frontend-module.ts:41
(anonymous) @ logger.ts:312
(anonymous) @ logger.ts:304
Promise.then (async)
../../packages/core/lib/common/logger.js.Logger.log @ logger.ts:299
log @ logger.ts:45
r @ backend.js:6
(anonymous) @ monaco-editor-model.js:560
step @ monaco-editor-model.js:58
(anonymous) @ monaco-editor-model.js:39
fulfilled @ monaco-editor-model.js:30
Promise.then (async)
step @ monaco-editor-model.js:32
(anonymous) @ monaco-editor-model.js:33
push.../../packages/monaco/lib/browser/monaco-editor-model.js.__awaiter @ monaco-editor-model.js:29
(anonymous) @ monaco-editor-model.js:520
(anonymous) @ event.ts:228
step @ event.ts:15
(anonymous) @ event.ts:15
fulfilled @ event.ts:15
Promise.then (async)
step @ event.ts:15
fulfilled @ event.ts:15
Promise.then (async)
step @ event.ts:15
(anonymous) @ event.ts:15
../../packages/core/lib/common/event.js.__awaiter @ event.ts:15
../../packages/core/lib/common/event.js.Emitter.sequence @ event.ts:225
(anonymous) @ monaco-editor-model.js:520
step @ monaco-editor-model.js:58
(anonymous) @ monaco-editor-model.js:39
(anonymous) @ monaco-editor-model.js:33
push.../../packages/monaco/lib/browser/monaco-editor-model.js.__awaiter @ monaco-editor-model.js:29
push.../../packages/monaco/lib/browser/monaco-editor-model.js.MonacoEditorModel.fireWillSaveModel @ monaco-editor-model.js:514
(anonymous) @ monaco-editor-model.js:488
step @ monaco-editor-model.js:58
(anonymous) @ monaco-editor-model.js:39
(anonymous) @ monaco-editor-model.js:33
push.../../packages/monaco/lib/browser/monaco-editor-model.js.__awaiter @ monaco-editor-model.js:29
push.../../packages/monaco/lib/browser/monaco-editor-model.js.MonacoEditorModel.doSave @ monaco-editor-model.js:480
(anonymous) @ monaco-editor-model.js:429
(anonymous) @ monaco-editor-model.js:316
step @ monaco-editor-model.js:58
(anonymous) @ monaco-editor-model.js:39
(anonymous) @ monaco-editor-model.js:33
push.../../packages/monaco/lib/browser/monaco-editor-model.js.__awaiter @ monaco-editor-model.js:29
(anonymous) @ monaco-editor-model.js:310
Promise.then (async)
push.../../packages/monaco/lib/browser/monaco-editor-model.js.MonacoEditorModel.run @ monaco-editor-model.js:310
push.../../packages/monaco/lib/browser/monaco-editor-model.js.MonacoEditorModel.scheduleSave @ monaco-editor-model.js:429
push.../../packages/monaco/lib/browser/monaco-editor-model.js.MonacoEditorModel.save @ monaco-editor-model.js:306
(anonymous) @ saveable.ts:69
step @ saveable.ts:15
(anonymous) @ saveable.ts:15
(anonymous) @ saveable.ts:15
../../packages/core/lib/browser/saveable.js.__awaiter @ saveable.ts:15
save @ saveable.ts:66
(anonymous) @ application-shell.ts:1561
step @ application-shell.ts:15
(anonymous) @ application-shell.ts:15
(anonymous) @ application-shell.ts:15
../../packages/core/lib/browser/shell/application-shell.js.__awaiter @ application-shell.ts:15
../../packages/core/lib/browser/shell/application-shell.js.ApplicationShell.save @ application-shell.ts:1560
execute @ common-frontend-contribution.ts:589
../../packages/core/lib/browser/keybinding.js.KeybindingRegistry.executeKeyBinding @ keybinding.ts:552
../../packages/core/lib/browser/keybinding.js.KeybindingRegistry.run @ keybinding.ts:609
(anonymous) @ frontend-application.ts:193

Note: both the user and the workspace JSON was invalid.

@akosyakov akosyakov self-assigned this Feb 11, 2020
@akosyakov
Copy link
Member

@kittaakos do you use standard setup and only edit to introduce invalid json file?

@RomanNikitenko
Copy link
Contributor

RomanNikitenko commented Feb 11, 2020

I can see similar errors at editing tasks.json file on each save.

tasks_json_errors

My steps to reproduce:

  1. Open as workspace https://github.com/eclipse-theia/theia/tree/master/packages/task/test-resources
  2. Try to edit tasks.json file and save your changes

@kittaakos
Copy link
Contributor Author

do you use standard setup

I am not sure what you mean, @akosyakov. I verified the behavior with #7110 in Gitpod.

@akosyakov
Copy link
Member

@kittaakos ok, i meant you did not add new VS Code extensions or something like that

@kittaakos
Copy link
Contributor Author

you did not add

Correct. No, I did not change anything.

@akosyakov
Copy link
Member

@RomanNikitenko can you reproduce it against #7110? Could you specify how do you edit? What do you enter and where?

@akosyakov
Copy link
Member

Can not add index to parent of type property

I cannot reproduce this issue.

onWillSave listeners should provide edits, not directly alter the document.

It's expected in case if there are some save participants mutating documents directly, it is just logging to bring attention. It does not break saving control flow.

I cannot reproduce the original issue in #7110, so will mark it as fixed.

@RomanNikitenko
Copy link
Contributor

RomanNikitenko commented Feb 11, 2020

@akosyakov
I just edit a label for a task, the error occurs when I press ctrl+s to save

errors

please give me 10 min to check it for the defined PR

@RomanNikitenko
Copy link
Contributor

RomanNikitenko commented Feb 11, 2020

@akosyakov
Checked, I can not reproduce my use case for #7110

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug bugs found in the application preferences issues related to preferences
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants