Security Policy yaml validation does not work with Vite

Summary

Locally, adding a schema for yaml files in the monaco-editor is throwing errors. Production there are no errors and the schema validation works fine.

It only happens for my usage of monaco-editor, so I think it has to do with how I am using yaml validation, which is not a native monaco-editor feature (we are using a monaco plugin called monaco-yaml. It also happens in the other place I implement yaml validation (single file editor for .gitlab/security-policies/policy.yml files). Also the error has registerSecurityPolicyEditorSchema source_editor_security_policy_schema_ext.js in it.

Errors
Uncaught Error: Unexpected usage

loadForeignModule@http://gdk.test:3443/vite-dev/@fs/Users/aturinske/gitlab-development-kit/gitlab/tmp/cache/vite/deps/chunk-YHBG4T57.js?v=e31c5f5a:36614:27
_getForeignProxy/this._foreignProxy<@http://gdk.test:3443/vite-dev/@fs/Users/aturinske/gitlab-development-kit/gitlab/tmp/cache/vite/deps/chunk-YHBG4T57.js?v=e31c5f5a:37092:22
promise callback*_getForeignProxy@http://gdk.test:3443/vite-dev/@fs/Users/aturinske/gitlab-development-kit/gitlab/tmp/cache/vite/deps/chunk-YHBG4T57.js?v=e31c5f5a:37090:45
getProxy@http://gdk.test:3443/vite-dev/@fs/Users/aturinske/gitlab-development-kit/gitlab/tmp/cache/vite/deps/chunk-YHBG4T57.js?v=e31c5f5a:37114:17
withSyncedResources/<@http://gdk.test:3443/vite-dev/@fs/Users/aturinske/gitlab-development-kit/gitlab/tmp/cache/vite/deps/chunk-YHBG4T57.js?v=e31c5f5a:37117:66
promise callback*withSyncedResources@http://gdk.test:3443/vite-dev/@fs/Users/aturinske/gitlab-development-kit/gitlab/tmp/cache/vite/deps/chunk-YHBG4T57.js?v=e31c5f5a:37117:49
getWorker@http://gdk.test:3443/vite-dev/@fs/Users/aturinske/gitlab-development-kit/gitlab/tmp/cache/vite/deps/monaco-yaml.js?v=e31c5f5a:118:21
provideMarkerData@http://gdk.test:3443/vite-dev/@fs/Users/aturinske/gitlab-development-kit/gitlab/tmp/cache/vite/deps/monaco-yaml.js?v=e31c5f5a:1629:28
doValidate@http://gdk.test:3443/vite-dev/@fs/Users/aturinske/gitlab-development-kit/gitlab/tmp/cache/vite/deps/monaco-yaml.js?v=e31c5f5a:23:36
onModelAdd@http://gdk.test:3443/vite-dev/@fs/Users/aturinske/gitlab-development-kit/gitlab/tmp/cache/vite/deps/monaco-yaml.js?v=e31c5f5a:39:15
fire@http://gdk.test:3443/vite-dev/@fs/Users/aturinske/gitlab-development-kit/gitlab/tmp/cache/vite/deps/chunk-YHBG4T57.js?v=e31c5f5a:3570:26
createModel@http://gdk.test:3443/vite-dev/@fs/Users/aturinske/gitlab-development-kit/gitlab/tmp/cache/vite/deps/chunk-YHBG4T57.js?v=e31c5f5a:31913:28
doCreateModel@http://gdk.test:3443/vite-dev/@fs/Users/aturinske/gitlab-development-kit/gitlab/tmp/cache/vite/deps/chunk-YHBG4T57.js?v=e31c5f5a:71947:23
createTextModel@http://gdk.test:3443/vite-dev/@fs/Users/aturinske/gitlab-development-kit/gitlab/tmp/cache/vite/deps/chunk-YHBG4T57.js?v=e31c5f5a:71944:10
createModel@http://gdk.test:3443/vite-dev/@fs/Users/aturinske/gitlab-development-kit/gitlab/tmp/cache/vite/deps/chunk-YHBG4T57.js?v=e31c5f5a:90519:10
createEditorModel@http://gdk.test:3443/vite-dev/javascripts/editor/source_editor.js:85:49
createInstance@http://gdk.test:3443/vite-dev/javascripts/editor/source_editor.js:135:28
initSourceEditor@http://gdk.test:3443/vite-dev/javascripts/vue_shared/components/source_editor.vue:15:12
mounted@http://gdk.test:3443/vite-dev/javascripts/vue_shared/components/source_editor.vue:75:19
invokeWithErrorHandling@http://gdk.test:3443/vite-dev/@fs/Users/aturinske/gitlab-development-kit/gitlab/tmp/cache/vite/deps/chunk-QACCEI5M.js?v=e31c5f5a:1968:57
callHook$1@http://gdk.test:3443/vite-dev/@fs/Users/aturinske/gitlab-development-kit/gitlab/tmp/cache/vite/deps/chunk-QACCEI5M.js?v=e31c5f5a:2561:30
insert@http://gdk.test:3443/vite-dev/@fs/Users/aturinske/gitlab-development-kit/gitlab/tmp/cache/vite/deps/chunk-QACCEI5M.js?v=e31c5f5a:6186:21
invokeInsertHook@http://gdk.test:3443/vite-dev/@fs/Users/aturinske/gitlab-development-kit/gitlab/tmp/cache/vite/deps/chunk-QACCEI5M.js?v=e31c5f5a:4402:31
patch2@http://gdk.test:3443/vite-dev/@fs/Users/aturinske/gitlab-development-kit/gitlab/tmp/cache/vite/deps/chunk-QACCEI5M.js?v=e31c5f5a:4569:21
lifecycleMixin/Vue2.prototype._update@http://gdk.test:3443/vite-dev/@fs/Users/aturinske/gitlab-development-kit/gitlab/tmp/cache/vite/deps/chunk-QACCEI5M.js?v=e31c5f5a:2341:19
updateComponent@http://gdk.test:3443/vite-dev/@fs/Users/aturinske/gitlab-development-kit/gitlab/tmp/cache/vite/deps/chunk-QACCEI5M.js?v=e31c5f5a:2420:10
node_modules/vue/dist/vue.runtime.esm.js/Watcher2.prototype.get@http://gdk.test:3443/vite-dev/@fs/Users/aturinske/gitlab-development-kit/gitlab/tmp/cache/vite/deps/chunk-QACCEI5M.js?v=e31c5f5a:6013:31
node_modules/vue/dist/vue.runtime.esm.js/Watcher2.prototype.run@http://gdk.test:3443/vite-dev/@fs/Users/aturinske/gitlab-development-kit/gitlab/tmp/cache/vite/deps/chunk-QACCEI5M.js?v=e31c5f5a:6067:28
flushSchedulerQueue@http://gdk.test:3443/vite-dev/@fs/Users/aturinske/gitlab-development-kit/gitlab/tmp/cache/vite/deps/chunk-QACCEI5M.js?v=e31c5f5a:2593:13
nextTick/<@http://gdk.test:3443/vite-dev/@fs/Users/aturinske/gitlab-development-kit/gitlab/tmp/cache/vite/deps/chunk-QACCEI5M.js?v=e31c5f5a:2015:12
flushCallbacks@http://gdk.test:3443/vite-dev/@fs/Users/aturinske/gitlab-development-kit/gitlab/tmp/cache/vite/deps/chunk-QACCEI5M.js?v=e31c5f5a:2007:14
promise callback*timerFunc@http://gdk.test:3443/vite-dev/@fs/Users/aturinske/gitlab-development-kit/gitlab/tmp/cache/vite/deps/chunk-QACCEI5M.js?v=e31c5f5a:5920:13
nextTick@http://gdk.test:3443/vite-dev/@fs/Users/aturinske/gitlab-development-kit/gitlab/tmp/cache/vite/deps/chunk-QACCEI5M.js?v=e31c5f5a:2025:5
queueWatcher@http://gdk.test:3443/vite-dev/@fs/Users/aturinske/gitlab-development-kit/gitlab/tmp/cache/vite/deps/chunk-QACCEI5M.js?v=e31c5f5a:2660:13
node_modules/vue/dist/vue.runtime.esm.js/Watcher2.prototype.update@http://gdk.test:3443/vite-dev/@fs/Users/aturinske/gitlab-development-kit/gitlab/tmp/cache/vite/deps/chunk-QACCEI5M.js?v=e31c5f5a:6062:23
    unexpectedErrorHandler errors.js:8
    setTimeout handler*node_modules/monaco-editor/esm/vs/base/common/errors.js/ErrorHandler/this.unexpectedErrorHandler errors.js:6
    onUnexpectedExternalError errors.js:25
    onUnexpectedExternalError errors.js:39
    promises codeAction.js:122
    rejected codeAction.js:9
    promise callback*step codeAction.js:10
    __awaiter4 codeAction.js:11
    __awaiter4 codeAction.js:7
    promises codeAction.js:101
    getCodeActions codeAction.js:101
    actions codeActionModel.js:202
    createCancelablePromise async.js:22
    value codeActionModel.js:202
    _createEventAndSignalChange codeActionModel.js:120
    trigger codeActionModel.js:41
    _update codeActionModel.js:208
    CodeActionModel codeActionModel.js:166
    fire event.js:424
    setModel codeEditorWidget.js:309
    createEditorModel source_editor.js:87
    createInstance source_editor.js:135
    initSourceEditor source_editor.vue:15
    mounted source_editor.vue:75
    VueJS 11
errors.js:8:26
Uncaught Error: Unexpected usage

loadForeignModule@http://gdk.test:3443/vite-dev/@fs/Users/aturinske/gitlab-development-kit/gitlab/tmp/cache/vite/deps/chunk-YHBG4T57.js?v=e31c5f5a:36614:27
_getForeignProxy/this._foreignProxy<@http://gdk.test:3443/vite-dev/@fs/Users/aturinske/gitlab-development-kit/gitlab/tmp/cache/vite/deps/chunk-YHBG4T57.js?v=e31c5f5a:37092:22
promise callback*_getForeignProxy@http://gdk.test:3443/vite-dev/@fs/Users/aturinske/gitlab-development-kit/gitlab/tmp/cache/vite/deps/chunk-YHBG4T57.js?v=e31c5f5a:37090:45
getProxy@http://gdk.test:3443/vite-dev/@fs/Users/aturinske/gitlab-development-kit/gitlab/tmp/cache/vite/deps/chunk-YHBG4T57.js?v=e31c5f5a:37114:17
withSyncedResources/<@http://gdk.test:3443/vite-dev/@fs/Users/aturinske/gitlab-development-kit/gitlab/tmp/cache/vite/deps/chunk-YHBG4T57.js?v=e31c5f5a:37117:66
promise callback*withSyncedResources@http://gdk.test:3443/vite-dev/@fs/Users/aturinske/gitlab-development-kit/gitlab/tmp/cache/vite/deps/chunk-YHBG4T57.js?v=e31c5f5a:37117:49
getWorker@http://gdk.test:3443/vite-dev/@fs/Users/aturinske/gitlab-development-kit/gitlab/tmp/cache/vite/deps/monaco-yaml.js?v=e31c5f5a:118:21
provideMarkerData@http://gdk.test:3443/vite-dev/@fs/Users/aturinske/gitlab-development-kit/gitlab/tmp/cache/vite/deps/monaco-yaml.js?v=e31c5f5a:1629:28
doValidate@http://gdk.test:3443/vite-dev/@fs/Users/aturinske/gitlab-development-kit/gitlab/tmp/cache/vite/deps/monaco-yaml.js?v=e31c5f5a:23:36
onModelAdd@http://gdk.test:3443/vite-dev/@fs/Users/aturinske/gitlab-development-kit/gitlab/tmp/cache/vite/deps/monaco-yaml.js?v=e31c5f5a:39:15
fire@http://gdk.test:3443/vite-dev/@fs/Users/aturinske/gitlab-development-kit/gitlab/tmp/cache/vite/deps/chunk-YHBG4T57.js?v=e31c5f5a:3570:26
createModel@http://gdk.test:3443/vite-dev/@fs/Users/aturinske/gitlab-development-kit/gitlab/tmp/cache/vite/deps/chunk-YHBG4T57.js?v=e31c5f5a:31913:28
doCreateModel@http://gdk.test:3443/vite-dev/@fs/Users/aturinske/gitlab-development-kit/gitlab/tmp/cache/vite/deps/chunk-YHBG4T57.js?v=e31c5f5a:71947:23
createTextModel@http://gdk.test:3443/vite-dev/@fs/Users/aturinske/gitlab-development-kit/gitlab/tmp/cache/vite/deps/chunk-YHBG4T57.js?v=e31c5f5a:71944:10
createModel@http://gdk.test:3443/vite-dev/@fs/Users/aturinske/gitlab-development-kit/gitlab/tmp/cache/vite/deps/chunk-YHBG4T57.js?v=e31c5f5a:90519:10
createEditorModel@http://gdk.test:3443/vite-dev/javascripts/editor/source_editor.js:85:49
createInstance@http://gdk.test:3443/vite-dev/javascripts/editor/source_editor.js:135:28
initSourceEditor@http://gdk.test:3443/vite-dev/javascripts/vue_shared/components/source_editor.vue:15:12
mounted@http://gdk.test:3443/vite-dev/javascripts/vue_shared/components/source_editor.vue:75:19
invokeWithErrorHandling@http://gdk.test:3443/vite-dev/@fs/Users/aturinske/gitlab-development-kit/gitlab/tmp/cache/vite/deps/chunk-QACCEI5M.js?v=e31c5f5a:1968:57
callHook$1@http://gdk.test:3443/vite-dev/@fs/Users/aturinske/gitlab-development-kit/gitlab/tmp/cache/vite/deps/chunk-QACCEI5M.js?v=e31c5f5a:2561:30
insert@http://gdk.test:3443/vite-dev/@fs/Users/aturinske/gitlab-development-kit/gitlab/tmp/cache/vite/deps/chunk-QACCEI5M.js?v=e31c5f5a:6186:21
invokeInsertHook@http://gdk.test:3443/vite-dev/@fs/Users/aturinske/gitlab-development-kit/gitlab/tmp/cache/vite/deps/chunk-QACCEI5M.js?v=e31c5f5a:4402:31
patch2@http://gdk.test:3443/vite-dev/@fs/Users/aturinske/gitlab-development-kit/gitlab/tmp/cache/vite/deps/chunk-QACCEI5M.js?v=e31c5f5a:4569:21
lifecycleMixin/Vue2.prototype._update@http://gdk.test:3443/vite-dev/@fs/Users/aturinske/gitlab-development-kit/gitlab/tmp/cache/vite/deps/chunk-QACCEI5M.js?v=e31c5f5a:2341:19
updateComponent@http://gdk.test:3443/vite-dev/@fs/Users/aturinske/gitlab-development-kit/gitlab/tmp/cache/vite/deps/chunk-QACCEI5M.js?v=e31c5f5a:2420:10
node_modules/vue/dist/vue.runtime.esm.js/Watcher2.prototype.get@http://gdk.test:3443/vite-dev/@fs/Users/aturinske/gitlab-development-kit/gitlab/tmp/cache/vite/deps/chunk-QACCEI5M.js?v=e31c5f5a:6013:31
node_modules/vue/dist/vue.runtime.esm.js/Watcher2.prototype.run@http://gdk.test:3443/vite-dev/@fs/Users/aturinske/gitlab-development-kit/gitlab/tmp/cache/vite/deps/chunk-QACCEI5M.js?v=e31c5f5a:6067:28
flushSchedulerQueue@http://gdk.test:3443/vite-dev/@fs/Users/aturinske/gitlab-development-kit/gitlab/tmp/cache/vite/deps/chunk-QACCEI5M.js?v=e31c5f5a:2593:13
nextTick/<@http://gdk.test:3443/vite-dev/@fs/Users/aturinske/gitlab-development-kit/gitlab/tmp/cache/vite/deps/chunk-QACCEI5M.js?v=e31c5f5a:2015:12
flushCallbacks@http://gdk.test:3443/vite-dev/@fs/Users/aturinske/gitlab-development-kit/gitlab/tmp/cache/vite/deps/chunk-QACCEI5M.js?v=e31c5f5a:2007:14
promise callback*timerFunc@http://gdk.test:3443/vite-dev/@fs/Users/aturinske/gitlab-development-kit/gitlab/tmp/cache/vite/deps/chunk-QACCEI5M.js?v=e31c5f5a:5920:13
nextTick@http://gdk.test:3443/vite-dev/@fs/Users/aturinske/gitlab-development-kit/gitlab/tmp/cache/vite/deps/chunk-QACCEI5M.js?v=e31c5f5a:2025:5
queueWatcher@http://gdk.test:3443/vite-dev/@fs/Users/aturinske/gitlab-development-kit/gitlab/tmp/cache/vite/deps/chunk-QACCEI5M.js?v=e31c5f5a:2660:13
node_modules/vue/dist/vue.runtime.esm.js/Watcher2.prototype.update@http://gdk.test:3443/vite-dev/@fs/Users/aturinske/gitlab-development-kit/gitlab/tmp/cache/vite/deps/chunk-QACCEI5M.js?v=e31c5f5a:6062:23
    unexpectedErrorHandler errors.js:8
    setTimeout handler*node_modules/monaco-editor/esm/vs/base/common/errors.js/ErrorHandler/this.unexpectedErrorHandler errors.js:6
    onUnexpectedExternalError errors.js:25
    onUnexpectedExternalError errors.js:39
    promise callback*getLinks/promises< getLinks.js:123
    getLinks getLinks.js:122
    computePromise links.js:184
    createCancelablePromise async.js:22
    beginCompute links.js:184
    __awaiter36 links.js:20
    __awaiter36 links.js:16
    beginCompute links.js:172
    onModelChanged links.js:162
    LinkDetector2 links.js:145
    fire event.js:424
    setModel codeEditorWidget.js:309
    createEditorModel source_editor.js:87
    createInstance source_editor.js:135
    initSourceEditor source_editor.vue:15
    mounted source_editor.vue:75
    VueJS 11
errors.js:8:26
Uncaught (in promise) Error: Unexpected usage
    loadForeignModule editorSimpleWorker.js:450
    _foreignProxy webWorker.js:38
    promise callback*_getForeignProxy webWorker.js:36
    getProxy webWorker.js:60
    withSyncedResources webWorker.js:63
    promise callback*withSyncedResources webWorker.js:63
    getWorker index.js:49
    provideMarkerData languageFeatures.ts:66
    doValidate index.js:21
    onModelAdd index.js:38
    fire event.js:424
    createModel modelServiceImpl.js:333
    doCreateModel standaloneCodeEditor.js:329
    createTextModel standaloneCodeEditor.js:323
    createModel standaloneEditor.js:93
    createEditorModel source_editor.js:85
    createInstance source_editor.js:135
    initSourceEditor source_editor.vue:15
    mounted source_editor.vue:75
    VueJS 16
editorSimpleWorker.js:450:30
Uncaught (in promise) Error: Unexpected usage
    loadForeignModule editorSimpleWorker.js:450
    _foreignProxy webWorker.js:38
    promise callback*_getForeignProxy webWorker.js:36
    getProxy webWorker.js:60
    withSyncedResources webWorker.js:63
    promise callback*withSyncedResources webWorker.js:63
    getWorker index.js:49
    provideMarkerData languageFeatures.ts:66
    doValidate index.js:21
    onModelAdd index.js:38
    registerMarkerDataProvider index.js:62
    setupMode yamlMode.ts:99
    fire event.js:424
    setDiagnosticsOptions index.ts:38
    setDiagnosticsOptions index.ts:66
    registerSchema utils.js:95
    registerSecurityPolicyEditorSchema source_editor_security_policy_schema_ext.js:63
    registerSchema yaml_editor.vue:63
    on yaml_editor.vue:74
    VueJS 4
    on source_editor.vue:102
    VueJS 3
    createInstance source_editor.js:152
    initSourceEditor source_editor.vue:15
    mounted source_editor.vue:75
    VueJS 17
editorSimpleWorker.js:450:30

Steps to reproduce

  1. Upload a GitLab Ultimate license to your GDK
  2. Navigate to a project/group => Secure => Policies => New policy => Scan execution policy => yaml mode
  3. Open the developer tools (CMD + Option + k)

Example Project

Vite is not in production yet http://gdk.test:3443/gitlab-org/gitlab-test/-/security/policies/new?type=scan_execution_policy

What is the current bug behavior?

yaml is not validated using the schema in yaml mode and the single file editor for .gitlab/security-policies/policy.yml files. Errors show in the console

What is the expected correct behavior?

yaml is validated using the schema in yaml mode and for the single file editor for .gitlab/security-policies/policy.yml files. No errors show

Relevant logs and/or screenshots

Output of checks

Results of GitLab environment info

Expand for output related to GitLab environment info

(For installations with omnibus-gitlab package run and paste the output of:
`sudo gitlab-rake gitlab:env:info`)

(For installations from source run and paste the output of:
`sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production`)

Results of GitLab application Check

Expand for output related to the GitLab application check

(For installations with omnibus-gitlab package run and paste the output of: sudo gitlab-rake gitlab:check SANITIZE=true)

(For installations from source run and paste the output of: sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production SANITIZE=true)

(we will only investigate if the tests are passing)

Possible fixes