{"record":{"id":"de945381e186ab14","repo":"tursodatabase/turso","slug":"path-is-not-an-elf-file","errorCode":null,"errorMessage":"{path} is not an ELF file","messagePattern":"(.+?) is not an ELF file","errorType":"console","errorClass":"SystemExit","httpStatus":null,"severity":"error","filePath":"bindings/dotnet/scripts/check_elf_dynsym_exports.py","lineNumber":94,"sourceCode":"    name: int,\n    typ: int,\n    flags: int,\n    offset: int,\n    size: int,\n    link: int,\n    info: int,\n    align: int,\n    entsize: int,\n) -> bytes:\n    return struct.pack(\n        \"<IIQQQQIIQQ\", name, typ, flags, 0, offset, size, link, info, align, entsize\n    )\n\n\ndef dynsym_names(path: Path) -> set[str]:\n    data = path.read_bytes()\n    if data[:4] != b\"\\x7fELF\":\n        raise SystemExit(f\"{path} is not an ELF file\")\n\n    layout = elf_layout(data, path)\n    dynsym = find_dynsym(data, layout, path)\n    return names_from_dynsym(data, layout, dynsym)\n\n\ndef elf_layout(data: bytes, path: Path) -> dict:\n    endian = \"<\" if data[5] == 1 else \">\"\n    elf_class = data[4]\n    if elf_class == 2:\n        return {\n            \"endian\": endian,\n            \"section_header_offset\": struct.unpack_from(endian + \"Q\", data, 40)[0],\n            \"section_header_size\": struct.unpack_from(endian + \"H\", data, 58)[0],\n            \"section_count\": struct.unpack_from(endian + \"H\", data, 60)[0],\n            \"string_table_index\": struct.unpack_from(endian + \"H\", data, 62)[0],\n            \"section_format\": endian + \"IIQQQQIIQQ\",\n            \"symbol_format\": endian + \"IBBHQQ\",","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/tursodatabase/turso/blob/492c4a71cd7c2649e7df83da1471b74f4b1c7aa9/bindings/dotnet/scripts/check_elf_dynsym_exports.py#L76-L112","documentation":"dynsym_names() reads the file and validates the ELF magic bytes (\\x7fELF) before parsing. If the first 4 bytes do not match, the path does not point to an ELF binary (it may be a text file, Mach-O/PE binary, script, or empty file). The script exits with this message and status 1.","triggerScenarios":"Calling missing_exports()/dynsym_names() on a path whose contents do not start with b'\\x7fELF' — e.g. checking a .dll, .dylib, or an archive file instead of an ELF .so.","commonSituations":"CI passes the wrong platform artifact (Windows .dll or macOS .dylib on a Linux check step), the path points to a stub or a text file, the build failed and a placeholder file exists, or a glob picked up non-ELF files.","solutions":["Verify the file is the Linux ELF artifact: `file <path>` should report 'ELF 64-bit'","Pass the correct .so path for the target platform; use platform-specific CI steps for .dll/.dylib","Check the build actually succeeded and produced a real binary, not an empty/partial file","If the file is genuinely an ELF but starts differently, check for corruption or accidental text wrapping"],"exampleFix":"// before\ncheck_elf_dynsym_exports.py build/libturso.dylib turso_sync_database_new\n// after\ncheck_elf_dynsym_exports.py build/libturso.so turso_sync_database_new","handlingStrategy":"validation","validationCode":"from pathlib import Path\npath = Path(elf_path)\nif not path.exists() or path.read_bytes()[:4] != b\"\\x7fELF\":\n    raise ValueError(f\"{path} is not an ELF file\")","typeGuard":"def is_elf(path) -> bool:\n    try:\n        return Path(path).read_bytes()[:4] == b\"\\x7fELF\"\n    except OSError:\n        return False","tryCatchPattern":"try:\n    subprocess.run([\"check_elf_dynsym_exports.py\", elf, *symbols], check=True)\nexcept SystemExit:\n    # or CalledProcessError when run via subprocess\n    # verify with `file <elf>` that the artifact is a Linux ELF .so\n    ...","preventionTips":["Validate the artifact type with `file <path>` before running the checker","Use platform-specific CI jobs so only ELF artifacts hit this script","Ensure the build completed before checking; a failed build can leave empty files"],"tags":["elf","file-format","python"],"backgroundTag":"incompatible-source-type","analyzedSha":"492c4a71cd7c2649e7df83da1471b74f4b1c7aa9","analyzedAt":"2026-09-13T18:13:59.796Z","contentChangedAt":"2026-09-13T18:13:59.796Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}