{"record":{"id":"5b3757ab1007d4a8","repo":"microsoft/typescript-go","slug":"w-could-not-read-file-q","errorCode":null,"errorMessage":"%w: could not read file %q","messagePattern":"%w: could not read file %q","errorType":"error_code","errorClass":"ErrClientError","httpStatus":null,"severity":"error","filePath":"internal/api/session.go","lineNumber":1208,"sourceCode":"\tparsedCommandLine := tsoptions.ParseJsonConfigFileContent(\n\t\tjsonValueToAny(params.JSON),\n\t\ts.projectSession,\n\t\tbasePath,\n\t\tnil, /*existingOptions*/\n\t\tconfigFileName,\n\t\tnil, /*resolutionStack*/\n\t\tnil, /*extraFileExtensions*/\n\t\tnil, /*extendedConfigCache*/\n\t)\n\treturn NewConfigFileResponse(parsedCommandLine), nil\n}\n\n// handleParseConfigFile parses a tsconfig.json file and returns its contents.\nfunc (s *Session) handleParseConfigFile(ctx context.Context, params *ParseConfigFileParams) (*ConfigFileResponse, error) {\n\tconfigFileName := params.File.ToAbsoluteFileName(s.projectSession.GetCurrentDirectory())\n\tconfigFileContent, ok := s.projectSession.FS().ReadFile(configFileName)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"%w: could not read file %q\", ErrClientError, configFileName)\n\t}\n\n\tconfigDir := tspath.GetDirectoryPath(configFileName)\n\ttsConfigSourceFile := tsoptions.NewTsconfigSourceFileFromFilePath(\n\t\tconfigFileName,\n\t\ts.toPath(configFileName),\n\t\tconfigFileContent,\n\t)\n\tparsedCommandLine := tsoptions.ParseJsonSourceFileConfigFileContent(\n\t\ttsConfigSourceFile,\n\t\ts.projectSession,\n\t\tconfigDir,\n\t\tnil, /*existingOptions*/\n\t\tnil, /*existingOptionsRaw*/\n\t\tconfigFileName,\n\t\tnil, /*resolutionStack*/\n\t\tnil, /*extraFileExtensions*/\n\t\tnil, /*extendedConfigCache*/","sourceCodeStart":1190,"sourceCodeEnd":1226,"githubUrl":"https://github.com/microsoft/typescript-go/blob/1bcfa18d79a3be41772223d5c05dfe4480e614ff/internal/api/session.go#L1190-L1226","documentation":"parseConfigFile could not read the tsconfig file from the server filesystem: FS().ReadFile returned !ok after normalizing params.File against the session's current directory. It means the file does not exist at the resolved absolute path, is unreadable, or the DocumentIdentifier's uri/fileName form resolves differently than the caller assumed.","triggerScenarios":"Passing a relative file name that normalizes against a different server cwd than expected; a URI whose FileName() form differs by case or separators from the on-disk path; the config file deleted or not checked out; permission denied on the file.","commonSituations":"Client and server in different working directories or containers; Windows path casing/separator mismatches; sparse checkouts missing the config; symlinks pointing outside the visible FS.","solutions":["Pass an absolute, normalized path in the file field","Verify the file exists from the server process's view before calling","Confirm the cwd the session was created with (it drives relative-path normalization) and send absolute paths to avoid depending on it"],"exampleFix":"// before\nparseConfigFile({file: \"tsconfig.json\"}) // relative; depends on server cwd\n\n// after\nparseConfigFile({file: \"/abs/path/to/project/tsconfig.json\"})","handlingStrategy":"validation","validationCode":"func readableConfig(absPath string) bool {\n    if !filepath.IsAbs(absPath) { return false }\n    info, err := os.Stat(absPath)\n    return err == nil && !info.IsDir()\n}\n// Note: the server stats this from ITS filesystem; verify from the same host/user when possible.","typeGuard":"func isAbsoluteFile(p string) bool { return filepath.IsAbs(p) }","tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"could not read file\") {\n    return fmt.Errorf(\"tsconfig not readable by server: %q (check path, case, permissions)\", cfgPath)\n}","preventionTips":["Send absolute, correctly-cased paths for config files","Confirm the server process's view of the filesystem (same container/mounts) before blaming the path","Check the session cwd used for normalization; absolute paths make it irrelevant"],"tags":["config","tsconfig","filesystem","paths","api"],"backgroundTag":null,"analyzedSha":"1bcfa18d79a3be41772223d5c05dfe4480e614ff","analyzedAt":"2026-08-16T02:12:00.115Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}