owasp-amass/amass · error
failed to obtain the embedded file %s: %v
Error message
failed to obtain the embedded file %s: %v
What it means
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.
Source
Thrown at internal/tools/file.go:45
}
// ensure that the permissions are set correctly
if err := os.Chmod(dir, 0755); err != nil {
return fmt.Errorf("failed to set permissions to 0755 for %s: %v", dir, err)
}
return nil
}
func CreateDefaultConfigFiles(dirpath string) error {
for _, filename := range resources.DefaultFilesList {
filepath := filepath.Join(dirpath, filename)
if _, err := os.Stat(filepath); !os.IsNotExist(err) {
// If the file already exists, skip creating it
continue
}
file, err := resources.GetResourceFile(filename)
if err != nil {
return fmt.Errorf("failed to obtain the embedded file %s: %v", filename, err)
}
defer func() { _ = file.Close() }()
// Create the default config file in the specified directory
outFile, err := os.Create(filepath)
if err != nil {
return fmt.Errorf("failed to create the output file %s: %v", filepath, err)
}
defer func() { _ = outFile.Close() }()
if _, err := io.Copy(outFile, file); err != nil {
return fmt.Errorf("failed to copy the file %s: %v", filepath, err)
}
}
return nil
}
View on GitHub (pinned to 79299dce87)
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
Example fix
// before (resources package) //go:embed configs var fsys embed.FS // after: ensure list matches //go:embed all:configs var fsys embed.FS // and DefaultFilesList entries like "configs/config.yaml"
Defensive patterns
Strategy: try-catch
Validate before calling
if _, err := fs.Stat(resources.FS, filename); err != nil {
return fmt.Errorf("embedded asset %s missing from build", filename)
} Type guard
func embeddedFileExists(name string) bool {
f, err := resources.GetResourceFile(name)
if err != nil { return false }
_ = f.Close()
return true
} Try / catch
if err := tools.CreateDefaultConfigFiles(dir); err != nil {
if strings.Contains(err.Error(), "failed to obtain the embedded file") {
return fmt.Errorf("build is missing embedded assets; reinstall the binary: %w", err)
}
return err
} Prevention
- 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
When it happens
Trigger: 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).
Common situations: 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.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- failed to obtain the embedded file: %s: %v
- failed to cast the DomainRecord
- failed to cast the IPNetRecord
- failed to cast the TLSCertificate asset
- failed to obtain the subject contact record
AI-assisted analysis of owasp-amass/amass@79299dce87 (2026-09-06).
Data as JSON: /api/errors/07a176094e51aa18.
Report an issue: GitHub.