{"record":{"id":"9e54fbe0ac1569fc","repo":"microsoft/monaco-editor","slug":"one-parameter-must-be-defined","errorCode":null,"errorMessage":"one parameter must be defined","messagePattern":"one parameter must be defined","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"website/src/website/pages/playground/Source.ts","lineNumber":55,"sourceCode":"\n\tpublic equals(other: Source | undefined): boolean {\n\t\tif (!other) {\n\t\t\treturn false;\n\t\t}\n\t\treturn other.toString() === this.toString();\n\t}\n\n\tconstructor(\n\t\tpublic readonly version: string | undefined,\n\t\tpublic readonly url: string | undefined,\n\t\tpublic readonly sourceLanguagesStr: string | undefined\n\t) {\n\t\tif (\n\t\t\tversion === undefined &&\n\t\t\turl === undefined &&\n\t\t\tsourceLanguagesStr === undefined\n\t\t) {\n\t\t\tthrow new Error(\"one parameter must be defined\");\n\t\t}\n\t}\n\n\tsourceToString(): string | undefined {\n\t\tif (this.url) {\n\t\t\treturn this.url;\n\t\t}\n\t\tif (this.version) {\n\t\t\treturn `v${this.version}`;\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tsourceLanguagesToString(): string | undefined {\n\t\treturn this.sourceLanguagesStr;\n\t}\n\n\ttoString() {","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/microsoft/monaco-editor/blob/ca1b42dc896b99db78e1c743256e8654e12cea2d/website/src/website/pages/playground/Source.ts#L37-L73","documentation":"Thrown by the playground Source constructor when all three parameters (version, url, sourceLanguagesStr) are undefined. A Source must identify where to load Monaco from — either an npm version, a direct URL, or at minimum a languages-source string — so an all-undefined instance is meaningless and is rejected at construction. The static factories (useLatest, useLatestDev, parse) always supply at least one field; direct `new Source(undefined, undefined, undefined)` is the trigger.","triggerScenarios":"Constructing `new Source(undefined, undefined, undefined)` directly; a refactor that passes three optional values that all happen to be undefined; calling Source.parse with a sourceStr that is neither 'latest', 'latest-dev', nor a 'v'-prefixed version AND sourceLanguagesStr is also undefined (parse falls through to `new Source(undefined, sourceStr, ...)` where sourceStr is undefined).","commonSituations":"URL/playground query params missing the source and languageSource keys; a default-settings change that leaves both npmVersion and coreUrl unset; programmatic Source creation where the caller forgot to supply a value.","solutions":["Provide at least one of version, url, or sourceLanguagesStr when constructing Source directly.","Prefer the static factories: `Source.useLatest()` or `Source.useLatestDev()` which always set a field.","If using Source.parse, ensure the input resolves to a known form ('latest', 'latest-dev', or 'vX.Y.Z'), or supply a non-empty sourceLanguagesStr as the fallback.","Validate upstream (query params/settings) so that at least one source field reaches the constructor."],"exampleFix":"// before\nconst source = new Source(undefined, undefined, undefined); // throws\n// after\nconst source = Source.useLatest(); // version = monacoEditorVersion\n// or\nconst source = new Source('0.34.0', undefined, undefined);","handlingStrategy":"type-guard","validationCode":"function makeSource(version?: string, url?: string, langs?: string): Source {\n  if (version === undefined && url === undefined && langs === undefined) {\n    // fall back to a sensible default rather than constructing an invalid Source\n    return Source.useLatest();\n  }\n  return new Source(version, url, langs);\n}","typeGuard":"function hasAnySourceField(version: string | undefined, url: string | undefined, langs: string | undefined): boolean {\n  return version !== undefined || url !== undefined || langs !== undefined;\n}","tryCatchPattern":null,"preventionTips":["Prefer the static factories (useLatest/useLatestDev) which always satisfy the invariant.","When parsing user input, default to 'latest' if no recognizable source string is present.","Validate playground query params upstream so an all-undefined Source is never constructed."],"tags":["runtime","website","playground","validation","constructor"],"backgroundTag":null,"analyzedSha":"ca1b42dc896b99db78e1c743256e8654e12cea2d","analyzedAt":"2026-08-13T02:00:51.380Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}