{"record":{"id":"480ac5719494ea48","repo":"commaai/openpilot","slug":"invalid-build-metadata","errorCode":null,"errorMessage":"invalid build metadata","messagePattern":"invalid build metadata","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"openpilot/common/version.py","lineNumber":156,"sourceCode":"  if build_metadata_path.exists():\n    build_metadata = json.loads(build_metadata_path.read_text())\n    return build_metadata_from_dict(build_metadata)\n\n  git_folder = pathlib.Path(path) / \".git\"\n\n  if git_folder.exists():\n    return BuildMetadata(get_short_branch(path),\n                    OpenpilotMetadata(\n                      version=get_version(path),\n                      release_notes=get_release_notes(path),\n                      git_commit=get_commit(path),\n                      git_origin=get_origin(path),\n                      git_commit_date=get_commit_date(path),\n                      build_style=\"unknown\",\n                      is_dirty=is_dirty(path)))\n\n  cloudlog.exception(\"unable to get build metadata\")\n  raise Exception(\"invalid build metadata\")\n\n\nif __name__ == \"__main__\":\n  print(get_build_metadata())\n","sourceCodeStart":138,"sourceCodeEnd":161,"githubUrl":"https://github.com/commaai/openpilot/blob/516ec1e68203439a73f340f1d0b3b91eabc626ee/openpilot/common/version.py#L138-L161","documentation":"get_build_metadata raises when neither a prebuilt build metadata file (BUILD_METADATA_FILENAME, e.g. githash / release JSON in the checkout root) nor a .git folder exists at the given path. openpilot can only describe itself from a release artifact or a git checkout; with neither, metadata is undeterminable.","triggerScenarios":"Calling get_build_metadata(path) on a source export created via 'git archive' or a tarball copy (no .git, no generated metadata file), or pointing path at a directory that is neither a checkout nor a release.","commonSituations":"Running openpilot code from a stripped-down copy, CI copying only sources without the release build step, or an incorrect BASEDIR (running from a different directory than the installed release).","solutions":["Run from a proper git clone of openpilot (restores the .git branch)","Or run from an installed release checkout, which ships the prebuilt metadata file","Verify the path passed/derived (e.g. BASEDIR) actually contains .git or the metadata file"],"exampleFix":"// before\nmd = get_build_metadata('/tmp/openpilot-copy')\n\n// after\nimport pathlib\npath = '/tmp/openpilot-copy'\nassert (pathlib.Path(path) / '.git').exists() or (pathlib.Path(path) / 'githash').exists(), 'run from a git checkout or release'\nmd = get_build_metadata(path)","handlingStrategy":"validation","validationCode":"import pathlib\nfrom openpilot.common.version import get_build_metadata, BUILD_METADATA_FILENAME\n\ndef build_metadata_available(path: str) -> bool:\n    p = pathlib.Path(path)\n    return (p / BUILD_METADATA_FILENAME).exists() or (p / '.git').exists()","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run openpilot from a git clone or an installed release, never from ad-hoc source copies","Ship the build metadata file in CI artifacts so stripped deployments still work"],"tags":["version","build","git","packaging"],"backgroundTag":null,"analyzedSha":"516ec1e68203439a73f340f1d0b3b91eabc626ee","analyzedAt":"2026-08-15T00:17:37.461Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}