{"record":{"id":"590098542b0c844f","repo":"microsoft/typescript-go","slug":"invalid-value-for-name-value","errorCode":null,"errorMessage":"Invalid value for ${name}: ${value}","messagePattern":"Invalid value for (.+?): (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"Herebyfile.mjs","lineNumber":57,"sourceCode":"    name = \"TSGO_HEREBY_\" + name.toUpperCase();\r\n\r\n    const value = process.env[name];\r\n    if (!value) {\r\n        return defaultValue;\r\n    }\r\n    switch (value.toUpperCase()) {\r\n        case \"1\":\r\n        case \"TRUE\":\r\n        case \"YES\":\r\n        case \"ON\":\r\n            return true;\r\n        case \"0\":\r\n        case \"FALSE\":\r\n        case \"NO\":\r\n        case \"OFF\":\r\n            return false;\r\n    }\r\n    throw new Error(`Invalid value for ${name}: ${value}`);\r\n}\r\n\r\nconst { values: rawOptions } = parseArgs({\r\n    args: process.argv.slice(2),\r\n    options: {\r\n        tests: { type: \"string\", short: \"t\" },\r\n        fix: { type: \"boolean\" },\r\n        debug: { type: \"boolean\" },\r\n        dirty: { type: \"boolean\" },\r\n        release: { type: \"boolean\" },\r\n\r\n        setPrerelease: { type: \"string\" },\r\n        forRelease: { type: \"boolean\" },\r\n\r\n        race: { type: \"boolean\", default: parseEnvBoolean(\"RACE\") },\r\n        noembed: { type: \"boolean\", default: parseEnvBoolean(\"NOEMBED\") },\r\n        concurrentTestPrograms: { type: \"boolean\", default: parseEnvBoolean(\"CONCURRENT_TEST_PROGRAMS\") },\r\n        coverage: { type: \"boolean\", default: parseEnvBoolean(\"COVERAGE\") },\r","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/microsoft/typescript-go/blob/1bcfa18d79a3be41772223d5c05dfe4480e614ff/Herebyfile.mjs#L39-L75","documentation":"Thrown by Session.getSnapshotAndDefaultProject when snapshot.GetDefaultProject(uri) returns nil, meaning the requested document does not belong to any loaded project in the current snapshot. This helper backs GetLanguageService, so any LSP feature that needs a language service (completions, quickinfo, formatting, diagnostics) fails with this error for out-of-project files. The lookup goes through Snapshot.ProjectCollection.GetDefaultProject on the file's normalized path (snapshot.go:82), so the URI must match a file actually contained in a project.","triggerScenarios":"Calling GetLanguageService (or any LSP handler routed through it: completion, hover, definition, document symbols, formatting) with a URI that (a) was never opened via textDocument/didOpen and isn't in any tsconfig's include/files, (b) sits outside all workspace folders / configured projects, (c) uses a scheme or casing that doesn't match (URI path vs host path, case-insensitive filesystem mismatch), or (d) arrives before project loading finished so the snapshot has no project containing it.","commonSituations":"Editor opens a stray .ts file outside the tsconfig.json include patterns; requests for untitled:/in-memory: URIs; a file that only matches an exclude pattern; requests racing server initialization (project still loading); typo'd or non-normalized URI passed by a custom LSP client; allowJs disabled while requesting a .js file.","solutions":["Verify the file is covered by a project: open it in the editor first (didOpen) or add it to the tsconfig.json include/files so ProjectCollection contains it.","If the request races initialization, retry after the server reports projects loaded (e.g., on initialize/project configuration complete) — GetDefaultProject returns nil until loading finishes.","Check the URI is a well-formed file URI pointing at the same path/casing the host FS reports, since the lookup is done on uri.Path(UseCaseSensitiveFileNames()).","If the file is intentionally outside the project (script file), route it through an inferred-project code path instead of GetDefaultProject, or configure the project (remove exclude, add allowJs) so it is contained."],"exampleFix":"// before: file not in any tsconfig -> \"no project found for URI ...\"\n// tsconfig.json\n{\n  \"include\": [\"src/**/*\"],\n  \"exclude\": [\"node_modules\"]\n}\n// after: stray file now included\n{\n  \"include\": [\"src/**/*\", \"tools/**/*\"]\n}","handlingStrategy":"type-guard","validationCode":"// before calling GetLanguageService / any feature routed through it:\nif len(snapshot.GetProjectsContainingFile(uri)) == 0 {\n\treturn emptyResult // or ask the client to open/include the file\n}","typeGuard":"func fileHasProject(snap *project.Snapshot, uri lsproto.DocumentUri) bool {\n\treturn snap.GetDefaultProject(uri) != nil\n}","tryCatchPattern":"if _, err := session.GetLanguageService(ctx, uri); err != nil {\n\tif strings.HasPrefix(err.Error(), \"no project found for URI\") {\n\t\treturn emptyResult // file outside project graph; degrade gracefully\n\t}\n\treturn err\n}","preventionTips":["Open documents via textDocument/didOpen before feature requests.","Keep tsconfig include/files covering every file you expect completions in.","Don't send requests before initialization/project loading completes.","Log the failing URI and compare it against the workspace root and tsconfig paths to catch normalization/casing mismatches."],"tags":["lsp","project-resolution","typescript","configuration"],"backgroundTag":null,"analyzedSha":"1bcfa18d79a3be41772223d5c05dfe4480e614ff","analyzedAt":"2026-08-16T02:12:00.115Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}