{"record":{"id":"9910168b454b7c24","repo":"apache/answer","slug":"read-file-failed-s-s","errorCode":null,"errorMessage":"read file failed: %s %s","messagePattern":"read file failed: (.+?) (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/base/translator/provider.go","lineNumber":76,"sourceCode":"\tentries, err := os.ReadDir(c.BundleDir)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// read the Bundle resources file from entries\n\tfor _, file := range entries {\n\t\t// ignore directory\n\t\tif file.IsDir() {\n\t\t\tcontinue\n\t\t}\n\t\t// ignore non-YAML file\n\t\tif filepath.Ext(file.Name()) != \".yaml\" && file.Name() != \"i18n.yaml\" {\n\t\t\tcontinue\n\t\t}\n\t\tlog.Debugf(\"try to read file: %s\", file.Name())\n\t\tbuf, err := os.ReadFile(filepath.Join(c.BundleDir, file.Name()))\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"read file failed: %s %s\", file.Name(), err)\n\t\t}\n\n\t\t// parse the backend translation\n\t\toriginalTr := struct {\n\t\t\tBackend map[string]map[string]any `yaml:\"backend\"`\n\t\t\tUI      map[string]any            `yaml:\"ui\"`\n\t\t\tPlugin  map[string]any            `yaml:\"plugin\"`\n\t\t}{}\n\t\tif err = yaml.Unmarshal(buf, &originalTr); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\ttranslation := make(map[string]any, 0)\n\t\tfor k, v := range originalTr.Backend {\n\t\t\ttranslation[k] = v\n\t\t}\n\t\ttranslation[\"backend\"] = originalTr.Backend\n\t\ttranslation[\"ui\"] = originalTr.UI\n\t\ttranslation[\"plugin\"] = originalTr.Plugin","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/apache/answer/blob/3b9f1370612e690a0b7f230f05e688930db4c6d3/internal/base/translator/provider.go#L58-L94","documentation":"NewTranslator scans the bundle directory for YAML translation files; when os.ReadFile fails on one of them it wraps the OS error as 'read file failed: <name> <err>'. It indicates an unreadable i18n bundle file (missing, permission, or path problem).","triggerScenarios":"os.ReadFile(filepath.Join(c.BundleDir, file.Name())) failing: file deleted between listing and read, wrong permissions, BundleDir pointing to a wrong/nonexistent location, or a broken symlink.","commonSituations":"Docker image missing translation files, i18n directory mounted with wrong permissions, packaging (build/embed) not including yaml files, or I18N bundle dir env var pointing to the wrong path.","solutions":["Check the file path printed in the error; verify the yaml file exists in the bundle dir (ls).","Fix file permissions (chmod/chown) so the process can read the yaml.","Verify the bundle dir configuration/env var points to the correct i18n directory.","Rebuild/redeploy ensuring translation yaml files are packaged (check Dockerfile COPY steps)."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"const p := filepath.Join(bundleDir, name)\nif info, err := os.Stat(p); err != nil || info.IsDir() { return fmt.Errorf(\"translation file unavailable: %s\", p) }","typeGuard":null,"tryCatchPattern":"tr, err := translator.NewTranslator(cfg)\nif err != nil {\n  if strings.HasPrefix(err.Error(), \"read file failed:\") {\n    log.Fatalf(\"i18n bundle unreadable: %v (check BundleDir=%s permissions)\", err, cfg.BundleDir)\n  }\n}","preventionTips":["Verify bundle dir path and permissions in deployment checks/healthchecks","COPY i18n files explicitly in Dockerfiles","Prefer go:embed or packaged assets over ad-hoc file reads","Test i18n initialization in CI against the packaged artifact"],"tags":["i18n","file-io","go","deployment"],"backgroundTag":"file-read-failed","analyzedSha":"3b9f1370612e690a0b7f230f05e688930db4c6d3","analyzedAt":"2026-09-05T18:18:39.533Z","contentChangedAt":"2026-09-05T18:18:39.533Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}