{"record":{"id":"fa8eae0bd9f86e58","repo":"t8y2/dbx","slug":"read-hive-initfile-w-fa8eae","errorCode":null,"errorMessage":"read Hive initFile: %w","messagePattern":"read Hive initFile: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agents/drivers/hive-go/config.go","lineNumber":1173,"sourceCode":"\nfunc prefixedParameters(values map[string]string, prefix string) map[string]string {\n\tresult := map[string]string{}\n\tfor key, value := range values {\n\t\tif len(key) <= len(prefix) || !strings.EqualFold(key[:len(prefix)], prefix) {\n\t\t\tcontinue\n\t\t}\n\t\tname := strings.TrimSpace(key[len(prefix):])\n\t\tif name != \"\" {\n\t\t\tresult[name] = value\n\t\t}\n\t}\n\treturn result\n}\n\nfunc readHiveInitFile(path string) ([]string, error) {\n\tfile, err := os.Open(path)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"read Hive initFile: %w\", err)\n\t}\n\tdefer file.Close()\n\n\tvar script strings.Builder\n\tscanner := bufio.NewScanner(file)\n\tscanner.Buffer(make([]byte, 0, 64*1024), 16*1024*1024)\n\tfor scanner.Scan() {\n\t\tline := strings.TrimSpace(scanner.Text())\n\t\tif line == \"\" || strings.HasPrefix(line, \"#\") || strings.HasPrefix(line, \"--\") {\n\t\t\tcontinue\n\t\t}\n\t\tscript.WriteString(line)\n\t\tscript.WriteByte(' ')\n\t}\n\tif err := scanner.Err(); err != nil {\n\t\treturn nil, fmt.Errorf(\"read Hive initFile: %w\", err)\n\t}\n","sourceCodeStart":1155,"sourceCodeEnd":1191,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/hive-go/config.go#L1155-L1191","documentation":"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).","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\ndsn := \"hive://user:pass@host:10000/db?initfile=./init.sql\"\n// after\ndsn := \"hive://user:pass@host:10000/db?initfile=/etc/hive/init.sql\"","handlingStrategy":"validation","validationCode":"p := params[\"initfile\"]\nif p != \"\" {\n    info, err := os.Stat(p)\n    if err != nil || info.IsDir() {\n        return fmt.Errorf(\"initfile not a readable file: %s\", p)\n    }\n}\n","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["configuration","file-io","go"],"backgroundTag":"init-file-unreadable","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"}