t8y2/dbx · error
read Hive initFile: %w
Error message
read Hive initFile: %w
What it means
This error wraps os.Open failures in readHiveInitFile (config.go:1173). The driver runs SQL statements from an initFile after connecting, and this error is returned when the init file cannot be opened. The wrapped error shows the OS-level reason (not found, permission denied, is-a-directory).
Source
Thrown at agents/drivers/hive-go/config.go:1173
func prefixedParameters(values map[string]string, prefix string) map[string]string {
result := map[string]string{}
for key, value := range values {
if len(key) <= len(prefix) || !strings.EqualFold(key[:len(prefix)], prefix) {
continue
}
name := strings.TrimSpace(key[len(prefix):])
if name != "" {
result[name] = value
}
}
return result
}
func readHiveInitFile(path string) ([]string, error) {
file, err := os.Open(path)
if err != nil {
return nil, fmt.Errorf("read Hive initFile: %w", err)
}
defer file.Close()
var script strings.Builder
scanner := bufio.NewScanner(file)
scanner.Buffer(make([]byte, 0, 64*1024), 16*1024*1024)
for scanner.Scan() {
line := strings.TrimSpace(scanner.Text())
if line == "" || strings.HasPrefix(line, "#") || strings.HasPrefix(line, "--") {
continue
}
script.WriteString(line)
script.WriteByte(' ')
}
if err := scanner.Err(); err != nil {
return nil, fmt.Errorf("read Hive initFile: %w", err)
}
View on GitHub (pinned to c0390bff16)
Solutions
- Verify the initFile path exists and is a regular readable file.
- Use an absolute path in the initfile parameter.
- Fix file permissions so the process user can read the script.
- Ensure the init script is included in the container image or mounted volume.
Example fix
// before dsn := "hive://user:pass@host:10000/db?initfile=./init.sql" // after dsn := "hive://user:pass@host:10000/db?initfile=/etc/hive/init.sql"
Defensive patterns
Strategy: validation
Validate before calling
p := params["initfile"]
if p != "" {
info, err := os.Stat(p)
if err != nil || info.IsDir() {
return fmt.Errorf("initfile not a readable file: %s", p)
}
}
Prevention
- Use absolute paths for initFile in all deployments.
- Ensure init scripts are baked into images or mounted before the driver starts.
- Add a startup check that opens and reads the init file before connecting.
When it happens
Trigger: The 'initfile' parameter points to a path that does not exist, is a directory, or is not readable by the process when the connector initializes the session.
Common situations: Relative initFile path that resolves differently inside a container; init script not baked into the image; read permissions after deploying as a non-root user; typo in the initfile parameter.
Related errors
- read Hive CA certificate: %w
- Hive host is required
- Hive endpoint is empty
- Hive JWT authentication requires jwt or the JWT environment
- Hive delegation token authentication requires delegationToke
AI-assisted analysis of t8y2/dbx@c0390bff16 (2026-09-05).
Data as JSON: /api/errors/fa8eae0bd9f86e58.
Report an issue: GitHub.