t8y2/dbx · error

Failed to resolve Oracle TNS file path: %w

Error message

Failed to resolve Oracle TNS file path: %w

What it means

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.

Source

Thrown at agents/drivers/oracle-go/tns.go:108

		return "", fmt.Errorf("Oracle TNS_ADMIN directory is not accessible: %s", path)
	}
	if !info.IsDir() {
		return "", fmt.Errorf("Oracle TNS_ADMIN must be a directory containing tnsnames.ora: %s", path)
	}
	tnsNamesPath := filepath.Join(path, "tnsnames.ora")
	if info, err := os.Stat(tnsNamesPath); err != nil || info.IsDir() {
		return "", fmt.Errorf("Oracle tnsnames.ora was not found in TNS_ADMIN directory: %s", path)
	}
	return tnsNamesPath, nil
}

func readOracleTNSAliases(path string, visited map[string]bool, depth int) (map[string]string, error) {
	if depth > 8 {
		return nil, fmt.Errorf("Oracle TNS include depth exceeds 8 files")
	}
	absolutePath, err := filepath.Abs(path)
	if err != nil {
		return nil, fmt.Errorf("Failed to resolve Oracle TNS file path: %w", err)
	}
	if visited[absolutePath] {
		return map[string]string{}, nil
	}
	visited[absolutePath] = true

	file, err := os.Open(absolutePath)
	if err != nil {
		return nil, fmt.Errorf("Failed to read Oracle TNS file %s: %w", absolutePath, err)
	}
	defer file.Close()

	aliases := make(map[string]string)
	var currentAliases []string
	var description strings.Builder
	descriptionStarted := false
	parenthesisDepth := 0
	flush := func() {

View on GitHub (pinned to c0390bff16)

Solutions

  1. Check that the process's current working directory exists and is accessible (ls -d $(pwd))
  2. Pass an already-absolute path for the TNS file so resolution is unambiguous
  3. Restart the agent process from a valid working directory
  4. Inspect the wrapped error (%w) for the underlying OS cause
  5. Avoid deleting/replacing the directory the process was started from

Example fix

// before: process cwd deleted, relative path fails
aliases, err := readOracleTNSAliases("tnsnames.ora", map[string]bool{}, 0)

// after: pass absolute path from a verified cwd
if _, err := os.Stat("/etc/oracle/tnsnames.ora"); err == nil {
    aliases, err = readOracleTNSAliases("/etc/oracle/tnsnames.ora", map[string]bool{}, 0)
}
Defensive patterns

Strategy: try-catch

Validate before calling

if _, err := os.Getwd(); err != nil {
    return fmt.Errorf("working directory unavailable, cannot resolve TNS path: %w", err)
}
if !filepath.IsAbs(tnsPath) {
    tnsPath = filepath.Join(validCwd, tnsPath)
}

Type guard

func pathResolvable(p string) bool {
    abs, err := filepath.Abs(p)
    return err == nil && abs != ""
}

Try / catch

aliases, err := resolveOracleTNSAlias(name)
if err != nil {
    var perr *fs.PathError
    if errors.As(err, &perr) {
        log.Printf("TNS path resolution failed for %s: %v", perr.Path, perr.Err)
    }
    return err
}

Prevention

When it happens

Trigger: Calling resolveOracleTNSAlias/readOracleTNSAliases when os.Getwd (used internally by filepath.Abs) fails — typically because the current working directory has been deleted or is inaccessible.

Common situations: 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.

Related errors


AI-assisted analysis of t8y2/dbx@c0390bff16 (2026-09-05). Data as JSON: /api/errors/3c77786052ab790e. Report an issue: GitHub.