{"record":{"id":"1f78c49a4ad54b8d","repo":"microsoft/monaco-editor","slug":"missing-vscode-ref-in-process-env","errorCode":null,"errorMessage":"Missing VSCODE_REF in process.env","messagePattern":"Missing VSCODE_REF in process\\.env","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/ci/env.ts","lineNumber":12,"sourceCode":"interface Env {\n\tVSCODE_REF: string;\n\tPRERELEASE_VERSION: string;\n}\n\nexport function getNightlyEnv(): Env {\n\tconst env: Env = process.env as any;\n\tif (!env.PRERELEASE_VERSION) {\n\t\tthrow new Error(`Missing PRERELEASE_VERSION in process.env`);\n\t}\n\tif (!env.VSCODE_REF) {\n\t\tthrow new Error(`Missing VSCODE_REF in process.env`);\n\t}\n\treturn env;\n}\n","sourceCodeStart":1,"sourceCodeEnd":16,"githubUrl":"https://github.com/microsoft/monaco-editor/blob/ca1b42dc896b99db78e1c743256e8654e12cea2d/scripts/ci/env.ts#L1-L16","documentation":"Thrown by getNightlyEnv() when process.env.VSCODE_REF is falsy. The nightly build uses VSCODE_REF as the git ref (branch/tag/commit) to shallow-clone from the VS Code repository when building monaco-editor-core, so the nightly monaco-editor tracks a specific VS Code revision. Without it the build cannot know which VS Code source to compile, so the guard aborts before any clone. PRERELEASE_VERSION is checked first, so this error only appears once that passes.","triggerScenarios":"Running the nightly core build (`build-monaco-editor-core-pkg.ts nightly`) when VSCODE_REF is unset/empty. Most common in CI when the ref variable wasn't wired into the nightly job, or when running the script locally without the var.","commonSituations":"CI workflow's nightly job missing the VSCODE_REF env injection; the secret renamed (e.g. from VSCODE_BRANCH) without updating the script; running the core nightly build outside the release pipeline; an environment scoping issue where the var exists in `prod` but not the job's environment.","solutions":["Export VSCODE_REF before running: `VSCODE_REF=main node scripts/ci/build-monaco-editor-core-pkg.ts nightly`.","In CI, add VSCODE_REF (a branch like `main` or `release/1.x`) to the nightly job's env or secrets.","Confirm the value is non-empty — empty string is falsy and still throws.","Pair it with PRERELEASE_VERSION since getNightlyEnv checks both."],"exampleFix":"// before\n$ PRERELEASE_VERSION=0.34.0-dev.20240101 node scripts/ci/build-monaco-editor-core-pkg.ts nightly\n// throws: Missing VSCODE_REF in process.env\n// after\n$ PRERELEASE_VERSION=0.34.0-dev.20240101 VSCODE_REF=main node scripts/ci/build-monaco-editor-core-pkg.ts nightly","handlingStrategy":"validation","validationCode":"if (!process.env.VSCODE_REF) {\n  console.error('VSCODE_REF (a VS Code git ref) is required for nightly core builds.');\n  process.exit(2);\n}\n// then run the nightly core build","typeGuard":"function hasVscodeRef(env: NodeJS.ProcessEnv): env is NodeJS.ProcessEnv & { VSCODE_REF: string } {\n  return Boolean(env.VSCODE_REF);\n}","tryCatchPattern":null,"preventionTips":["Pair VSCODE_REF with PRERELEASE_VERSION in the same CI env block so one isn't missed.","Default the ref to a known branch in non-production nightly test runs.","Add a CI preflight step that prints which env vars are set (names only) for quick diagnosis."],"tags":["ci","environment","release","nightly","git-ref"],"backgroundTag":null,"analyzedSha":"ca1b42dc896b99db78e1c743256e8654e12cea2d","analyzedAt":"2026-08-13T02:00:51.380Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}