{"record":{"id":"07a176094e51aa18","repo":"owasp-amass/amass","slug":"failed-to-obtain-the-embedded-file-s-v","errorCode":null,"errorMessage":"failed to obtain the embedded file %s: %v","messagePattern":"failed to obtain the embedded file (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/tools/file.go","lineNumber":45,"sourceCode":"\t}\n\t// ensure that the permissions are set correctly\n\tif err := os.Chmod(dir, 0755); err != nil {\n\t\treturn fmt.Errorf(\"failed to set permissions to 0755 for %s: %v\", dir, err)\n\t}\n\treturn nil\n}\n\nfunc CreateDefaultConfigFiles(dirpath string) error {\n\tfor _, filename := range resources.DefaultFilesList {\n\t\tfilepath := filepath.Join(dirpath, filename)\n\t\tif _, err := os.Stat(filepath); !os.IsNotExist(err) {\n\t\t\t// If the file already exists, skip creating it\n\t\t\tcontinue\n\t\t}\n\n\t\tfile, err := resources.GetResourceFile(filename)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to obtain the embedded file %s: %v\", filename, err)\n\t\t}\n\t\tdefer func() { _ = file.Close() }()\n\n\t\t// Create the default config file in the specified directory\n\t\toutFile, err := os.Create(filepath)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to create the output file %s: %v\", filepath, err)\n\t\t}\n\t\tdefer func() { _ = outFile.Close() }()\n\n\t\tif _, err := io.Copy(outFile, file); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to copy the file %s: %v\", filepath, err)\n\t\t}\n\t}\n\treturn nil\n}\n","sourceCodeStart":27,"sourceCodeEnd":62,"githubUrl":"https://github.com/owasp-amass/amass/blob/79299dce87b0085db0f2f4ef3e9c52cccb49f514/internal/tools/file.go#L27-L62","documentation":"CreateDefaultConfigFiles materializes embedded default config files into the output directory. resources.GetResourceFile retrieves a file embedded via go:embed; this error means the named default file could not be obtained from the embedded resource filesystem — a build/packaging anomaly rather than a user configuration issue.","triggerScenarios":"The requested filename is not present in the resources embed.FS (e.g. DefaultFilesList and the embedded assets are out of sync), or the embedded FS lookup path is wrong (missing subdirectory prefix).","commonSituations":"Custom builds where assets were stripped or the embed pattern was narrowed, vendored/module download corruption, or renaming a default file in DefaultFilesList without adding it to the embedded assets.","solutions":["Rebuild from a clean checkout (go clean -cache && go build) so embed directives pick up all assets","Verify the filename exists in the resources package embed directory and that the embed pattern covers it","Check that DefaultFilesList entries match the embedded file paths exactly (case-sensitive)","If using a packaged binary, reinstall the official release"],"exampleFix":"// before (resources package)\n//go:embed configs\nvar fsys embed.FS\n// after: ensure list matches\n//go:embed all:configs\nvar fsys embed.FS\n// and DefaultFilesList entries like \"configs/config.yaml\"","handlingStrategy":"try-catch","validationCode":"if _, err := fs.Stat(resources.FS, filename); err != nil {\n\treturn fmt.Errorf(\"embedded asset %s missing from build\", filename)\n}","typeGuard":"func embeddedFileExists(name string) bool {\n\tf, err := resources.GetResourceFile(name)\n\tif err != nil { return false }\n\t_ = f.Close()\n\treturn true\n}","tryCatchPattern":"if err := tools.CreateDefaultConfigFiles(dir); err != nil {\n\tif strings.Contains(err.Error(), \"failed to obtain the embedded file\") {\n\t\treturn fmt.Errorf(\"build is missing embedded assets; reinstall the binary: %w\", err)\n\t}\n\treturn err\n}","preventionTips":["Build from a clean checkout so go:embed includes all assets","Keep resources.DefaultFilesList and the embed directory in sync in code review","Verify packaged binaries with official releases or checksums","Add a smoke test that calls GetResourceFile for every DefaultFilesList entry"],"tags":["go","embed","resources","packaging"],"backgroundTag":"resource-not-found","analyzedSha":"79299dce87b0085db0f2f4ef3e9c52cccb49f514","analyzedAt":"2026-09-06T08:22:48.198Z","contentChangedAt":"2026-09-06T08:22:48.198Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}