{"record":{"id":"3c77786052ab790e","repo":"t8y2/dbx","slug":"failed-to-resolve-oracle-tns-file-path-w","errorCode":null,"errorMessage":"Failed to resolve Oracle TNS file path: %w","messagePattern":"Failed to resolve Oracle TNS file path: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agents/drivers/oracle-go/tns.go","lineNumber":108,"sourceCode":"\t\treturn \"\", fmt.Errorf(\"Oracle TNS_ADMIN directory is not accessible: %s\", path)\n\t}\n\tif !info.IsDir() {\n\t\treturn \"\", fmt.Errorf(\"Oracle TNS_ADMIN must be a directory containing tnsnames.ora: %s\", path)\n\t}\n\ttnsNamesPath := filepath.Join(path, \"tnsnames.ora\")\n\tif info, err := os.Stat(tnsNamesPath); err != nil || info.IsDir() {\n\t\treturn \"\", fmt.Errorf(\"Oracle tnsnames.ora was not found in TNS_ADMIN directory: %s\", path)\n\t}\n\treturn tnsNamesPath, nil\n}\n\nfunc readOracleTNSAliases(path string, visited map[string]bool, depth int) (map[string]string, error) {\n\tif depth > 8 {\n\t\treturn nil, fmt.Errorf(\"Oracle TNS include depth exceeds 8 files\")\n\t}\n\tabsolutePath, err := filepath.Abs(path)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"Failed to resolve Oracle TNS file path: %w\", err)\n\t}\n\tif visited[absolutePath] {\n\t\treturn map[string]string{}, nil\n\t}\n\tvisited[absolutePath] = true\n\n\tfile, err := os.Open(absolutePath)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"Failed to read Oracle TNS file %s: %w\", absolutePath, err)\n\t}\n\tdefer file.Close()\n\n\taliases := make(map[string]string)\n\tvar currentAliases []string\n\tvar description strings.Builder\n\tdescriptionStarted := false\n\tparenthesisDepth := 0\n\tflush := func() {","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/oracle-go/tns.go#L90-L126","documentation":"Before opening a TNS file, readOracleTNSAliases converts the given path to an absolute path with filepath.Abs and wraps any failure in this error. filepath.Abs essentially only fails if the working directory cannot be determined (e.g. the process cwd was deleted). The wrapped OS error is included via %w.","triggerScenarios":"Calling resolveOracleTNSAlias/readOracleTNSAliases when os.Getwd (used internally by filepath.Abs) fails — typically because the current working directory has been deleted or is inaccessible.","commonSituations":"A long-running agent whose working directory was removed or recreated; running inside a container where the cwd mount vanished; spawning the process from a deleted temp directory before resolving TNS paths.","solutions":["Check that the process's current working directory exists and is accessible (ls -d $(pwd))","Pass an already-absolute path for the TNS file so resolution is unambiguous","Restart the agent process from a valid working directory","Inspect the wrapped error (%w) for the underlying OS cause","Avoid deleting/replacing the directory the process was started from"],"exampleFix":"// before: process cwd deleted, relative path fails\naliases, err := readOracleTNSAliases(\"tnsnames.ora\", map[string]bool{}, 0)\n\n// after: pass absolute path from a verified cwd\nif _, err := os.Stat(\"/etc/oracle/tnsnames.ora\"); err == nil {\n    aliases, err = readOracleTNSAliases(\"/etc/oracle/tnsnames.ora\", map[string]bool{}, 0)\n}","handlingStrategy":"try-catch","validationCode":"if _, err := os.Getwd(); err != nil {\n    return fmt.Errorf(\"working directory unavailable, cannot resolve TNS path: %w\", err)\n}\nif !filepath.IsAbs(tnsPath) {\n    tnsPath = filepath.Join(validCwd, tnsPath)\n}","typeGuard":"func pathResolvable(p string) bool {\n    abs, err := filepath.Abs(p)\n    return err == nil && abs != \"\"\n}","tryCatchPattern":"aliases, err := resolveOracleTNSAlias(name)\nif err != nil {\n    var perr *fs.PathError\n    if errors.As(err, &perr) {\n        log.Printf(\"TNS path resolution failed for %s: %v\", perr.Path, perr.Err)\n    }\n    return err\n}","preventionTips":["Start agents from a stable, existing working directory","Pass absolute TNS file paths in configuration","Avoid deleting/replacing the cwd of running processes"],"tags":["oracle","tns","filesystem","path-resolution"],"backgroundTag":"path-resolution-failed","analyzedSha":"c0390bff16418b651f4728520d99adf8ce48829a","analyzedAt":"2026-09-05T23:05:10.900Z","contentChangedAt":"2026-09-05T23:05:10.900Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}