{"record":{"id":"06365f0c5b17d59e","repo":"microsoft/monaco-editor","slug":"invalid-language-id-this-languageid","errorCode":null,"errorMessage":"Invalid language id: ${this._languageId}","messagePattern":"Invalid language id: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/languages/features/css/cssWorker.ts","lineNumber":48,"sourceCode":"\t\t\t}\n\t\t}\n\t\tconst lsOptions: cssService.LanguageServiceOptions = {\n\t\t\tcustomDataProviders,\n\t\t\tuseDefaultDataProvider\n\t\t};\n\n\t\tswitch (this._languageId) {\n\t\t\tcase 'css':\n\t\t\t\tthis._languageService = cssService.getCSSLanguageService(lsOptions);\n\t\t\t\tbreak;\n\t\t\tcase 'less':\n\t\t\t\tthis._languageService = cssService.getLESSLanguageService(lsOptions);\n\t\t\t\tbreak;\n\t\t\tcase 'scss':\n\t\t\t\tthis._languageService = cssService.getSCSSLanguageService(lsOptions);\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow new Error('Invalid language id: ' + this._languageId);\n\t\t}\n\t\tthis._languageService.configure(this._languageSettings);\n\t}\n\n\t// --- language service host ---------------\n\n\tasync doValidation(uri: string): Promise<cssService.Diagnostic[]> {\n\t\tconst document = this._getTextDocument(uri);\n\t\tif (document) {\n\t\t\tconst stylesheet = this._languageService.parseStylesheet(document);\n\t\t\tconst diagnostics = this._languageService.doValidation(document, stylesheet);\n\t\t\treturn Promise.resolve(diagnostics);\n\t\t}\n\t\treturn Promise.resolve([]);\n\t}\n\tasync doComplete(\n\t\turi: string,\n\t\tposition: cssService.Position","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/microsoft/monaco-editor/blob/ca1b42dc896b99db78e1c743256e8654e12cea2d/src/languages/features/css/cssWorker.ts#L30-L66","documentation":"Thrown by the CSS worker constructor when the language id passed via createData.languageId is not one of 'css', 'less', or 'scss'. The worker maps the id to the matching vscode-css-languageservice factory (getCSSLanguageService / getLESSLanguageService / getSCSSLanguageService); an unknown id has no language service to instantiate, so it throws during worker initialization. The id originates from cssDefaults/scssDefaults/lessDefaults.languageId and is forwarded by workerManager.","triggerScenarios":"Constructing a custom LanguageServiceDefaults with a languageId outside the allowed set (e.g. 'sass' or 'stylus') and wiring it into setupMode; manually instantiating the CSS worker with createData.languageId set to an unsupported value; registering the CSS worker against a model whose language was changed to something else.","commonSituations":"Developer forks the CSS integration to support another CSS-like language and forgets to extend the switch; misconfiguration where the model's language id and the worker's createData disagree; passing the wrong defaults object to setupMode.","solutions":["Use one of the three built-in language ids ('css', 'less', 'scss') for the model and the matching defaults (cssDefaults/scssDefaults/lessDefaults).","If you need a custom CSS dialect, map it to the closest built-in service (e.g. route 'sass' through getSCSSLanguageService) by extending the switch and rebuilding the worker.","Verify the language registered with `monaco.languages.register` matches the languageId on the defaults passed to setupMode.","Check that you didn't pass the wrong defaults object (e.g. cssDefaults for a scss model) when calling setupMode."],"exampleFix":"// before — custom dialect routed to CSS worker with unsupported id\nmonaco.languages.register({ id: 'sass' });\n// ...setupMode called with sassDefaults whose languageId='sass' -> worker throws\n// after — map the dialect to an existing service or extend the worker switch\n// in cssWorker.ts switch: case 'sass': this._languageService = cssService.getSCSSLanguageService(lsOptions); break;","handlingStrategy":"type-guard","validationCode":"const SUPPORTED_CSS_LANG_IDS = new Set(['css', 'less', 'scss']);\nfunction validateCssLanguageId(id: string) {\n  if (!SUPPORTED_CSS_LANG_IDS.has(id)) {\n    throw new Error(`Unsupported CSS language id '${id}'. Use one of: css, less, scss.`);\n  }\n}\nvalidateCssLanguageId(defaults.languageId);","typeGuard":"function isCssLanguageId(id: string): id is 'css' | 'less' | 'scss' {\n  return id === 'css' || id === 'less' || id === 'scss';\n}","tryCatchPattern":null,"preventionTips":["Only register CSS/LESS/SCSS models against their corresponding defaults.","If adding a CSS-like dialect, extend the cssWorker switch and rebuild.","Double-check that the model's language id matches the defaults.languageId passed to setupMode."],"tags":["runtime","css","language-services","language-id","worker"],"backgroundTag":null,"analyzedSha":"ca1b42dc896b99db78e1c743256e8654e12cea2d","analyzedAt":"2026-08-13T02:00:51.380Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}