apache/beam · error

Unknown file format

Error message

Unknown file format

What it means

Returned by symbolData in the symtab package after it tried and failed to parse the given file as ELF, Mach-O, and Windows PE in sequence. It means the on-disk object being loaded for symbol resolution is none of the supported executable formats — typically a truncated/corrupt binary, a text file, or a format this Go target cannot parse.

Solutions

  1. Ensure the path points to a real executable binary built for the running platform
  2. Verify with `file <path>` that the binary is ELF/Mach-O/PE and uncorrupted
  3. Rebuild or re-download the binary if it is truncated
  4. Note that the caller may see this as an empty symbol table rather than a hard failure depending on New's error handling

Example fix

// verify before use
out, _ := exec.Command("file", binPath).CombinedOutput()
if !strings.Contains(string(out), "ELF") && !strings.Contains(string(out), "Mach-O") && !strings.Contains(string(out), "PE32") {
    return fmt.Errorf("%s is not a supported executable format", binPath)
}
st, err := symtab.New(binPath)
Defensive patterns

Strategy: validation

Validate before calling

out, err := exec.Command("file", binPath).CombinedOutput()
supported := strings.Contains(string(out), "ELF") || strings.Contains(string(out), "Mach-O") || strings.Contains(string(out), "PE32")
if err != nil || !supported { return fmt.Errorf("%s: unsupported binary format", binPath) }

Try / catch

m, r, err := symtab.New(binPath)
if err != nil {
    if strings.Contains(err.Error(), "Unknown file format") { return fmt.Errorf("%s is not ELF/Mach-O/PE", binPath) }
    return err
}

Prevention

When it happens

Trigger: Calling symtab.New on a binary that is not a valid ELF, Mach-O, or PE executable (or is corrupt/compressed).

Common situations: Pointing the symbol table at scripts, text files, or stripped/obfuscated binaries; attaching to a binary from an incompatible architecture or OS; passing a compressed binary (e.g. upx-packed or a .gz file).

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of apache/beam@12126d8942 (2026-09-13). Data as JSON: /api/errors/0e2149d315bfbdfc. Report an issue: GitHub.

Appendix: source

Thrown at sdks/go/pkg/beam/core/util/symtab/symtab.go:94

	ef, err := elf.NewFile(f)
	if err == nil {
		return elfSymbolData(ef)
	}

	// then Mach-O
	mf, err := macho.NewFile(f)
	if err == nil {
		return machoSymbolData(mf)
	}

	// finally try Windows PE format
	pf, err := pe.NewFile(f)
	if err == nil {
		return peSymbolData(pf)
	}

	// Give up, we don't recognize it
	return nil, nil, errors.New("Unknown file format")
}

// elfSymbolData builds function symbol maps from an ELF file.
func elfSymbolData(ef *elf.File) (map[uintptr]string, map[string]uintptr, error) {
	syms, err := ef.Symbols()
	if err != nil {
		return nil, nil, err
	}
	addr2Sym := make(map[uintptr]string)
	sym2Addr := make(map[string]uintptr)
	for _, sym := range syms {
		if elf.ST_TYPE(sym.Info) != elf.STT_FUNC {
			continue
		}
		value := uintptr(sym.Value)
		addr2Sym[value] = sym.Name
		sym2Addr[sym.Name] = value
	}

View on GitHub (pinned to 12126d8942)