{"record":{"id":"70e64205709c3bda","repo":"t8y2/dbx","slug":"oracle-tns-admin-directory-is-not-accessible-s","errorCode":null,"errorMessage":"Oracle TNS_ADMIN directory is not accessible: %s","messagePattern":"Oracle TNS_ADMIN directory is not accessible: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agents/drivers/oracle-go/tns.go","lineNumber":90,"sourceCode":"\tif err != nil {\n\t\treturn \"\", err\n\t}\n\taliases, err := readOracleTNSAliases(tnsNamesPath, make(map[string]bool), 0)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tdescriptor, ok := aliases[strings.ToUpper(config.Alias)]\n\tif !ok {\n\t\treturn \"\", fmt.Errorf(\"Oracle TNS alias %q was not found in %s\", config.Alias, tnsNamesPath)\n\t}\n\treturn descriptor, nil\n}\n\nfunc oracleTNSNamesPath(tnsAdmin string) (string, error) {\n\tpath := filepath.Clean(strings.TrimSpace(tnsAdmin))\n\tinfo, err := os.Stat(path)\n\tif err != nil {\n\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)","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/oracle-go/tns.go#L72-L108","documentation":"oracleTNSNamesPath validates the TNS_ADMIN directory by calling os.Stat on the cleaned path. If Stat fails (missing path, permission denied, bad symlink), the driver cannot locate tnsnames.ora and returns this error with the offending path.","triggerScenarios":"resolveOracleTNSAlias -> oracleTNSNamesPath receives a TNS_ADMIN value whose path does not exist or is not statable — e.g. a typo'd directory, a path valid on the host but not inside a container, or a permission-blocked directory.","commonSituations":"TNS_ADMIN set in the JDBC URL/host but the directory only exists on a developer laptop; containerized deployments forgetting to mount the Oracle network admin directory; wrong user permissions (directory owned by another UID); macOS vs Linux path differences.","solutions":["Verify the path exists: ls -ld <TNS_ADMIN>; fix typos in the configured value.","In containers, mount the directory (docker run -v /host/admin:/opt/oracle/network/admin ...) and use the in-container path.","Fix permissions so the process user can traverse the directory (chmod/chown).","Ensure the value passed in the URL is the server/container filesystem path, not the client machine's path."],"exampleFix":"// before\ndsn := \"jdbc:oracle:thin:@ALIAS?TNS_ADMIN=/Users/me/Oracle/admin\" // path only on laptop\n// after (in container)\ndsn := \"jdbc:oracle:thin:@ALIAS?TNS_ADMIN=/opt/oracle/network/admin\"","handlingStrategy":"validation","validationCode":"info, err := os.Stat(tnsAdmin)\nif err != nil || !info.IsDir() {\n\treturn fmt.Errorf(\"TNS_ADMIN %q must be an existing directory\", tnsAdmin)\n}","typeGuard":null,"tryCatchPattern":"if strings.Contains(err.Error(), \"TNS_ADMIN directory is not accessible\") {\n\treturn fmt.Errorf(\"mount or create the TNS_ADMIN directory and fix permissions: %w\", err)\n}","preventionTips":["Check the directory exists inside the same container/host that runs the driver.","Add an os.Stat readiness check to startup before first connection.","Mount Oracle network admin dirs explicitly in container images/compose files.","Run the process as a user with traverse permission on the directory."],"tags":["oracle","tns","filesystem","config"],"backgroundTag":"file-not-found","analyzedSha":"c0390bff16418b651f4728520d99adf8ce48829a","analyzedAt":"2026-09-05T23:05:10.900Z","contentChangedAt":"2026-09-05T23:05:10.900Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}