{"record":{"id":"19054b6d687e01bc","repo":"commaai/openpilot","slug":"could-not-find-segments-for-route-self-name-canon","errorCode":null,"errorMessage":"Could not find segments for route {self.name.canonical_name} in data directory {data_dir}","messagePattern":"Could not find segments for route (.+?) in data directory (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"openpilot/tools/lib/route.py","lineNumber":163,"sourceCode":"      try:\n        dcamera_path = next(path for path, filename in files if filename in FileName.DCAMERA)\n      except StopIteration:\n        dcamera_path = None\n\n      try:\n        ecamera_path = next(path for path, filename in files if filename in FileName.ECAMERA)\n      except StopIteration:\n        ecamera_path = None\n\n      try:\n        qcamera_path = next(path for path, filename in files if filename in FileName.QCAMERA)\n      except StopIteration:\n        qcamera_path = None\n\n      segments.append(Segment(segment, log_path, qlog_path, camera_path, dcamera_path, ecamera_path, qcamera_path))\n\n    if len(segments) == 0:\n      raise ValueError(f'Could not find segments for route {self.name.canonical_name} in data directory {data_dir}')\n    return sorted(segments, key=lambda seg: seg.name.segment_num)\n\n\nclass Segment:\n  def __init__(self, name, log_path, qlog_path, camera_path, dcamera_path, ecamera_path, qcamera_path):\n    self._events = None\n    self._name = SegmentName(name)\n    self.log_path = log_path\n    self.qlog_path = qlog_path\n    self.camera_path = camera_path\n    self.dcamera_path = dcamera_path\n    self.ecamera_path = ecamera_path\n    self.qcamera_path = qcamera_path\n\n  @property\n  def name(self):\n    return self._name\n","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/commaai/openpilot/blob/516ec1e68203439a73f340f1d0b3b91eabc626ee/openpilot/tools/lib/route.py#L145-L181","documentation":"Route.database_files()/local resolution scans a data directory for segment subdirectories matching the route name; if zero segments are found it raises ValueError naming the route and directory. The directory exists as a structure but contains nothing recognizable for that dongle|time.","triggerScenarios":"Constructing Route(..., data_dir=...) where data_dir lacks '<dongle_id>|<time>--<seg>' folders — wrong dir, wrong route string, or the segment folders were renamed/moved.","commonSituations":"Pointing at an extracted-but-flattened dump; dongle ID or timestamp typo; data laid out for a different openpilot version's naming scheme.","solutions":["List the data dir and confirm folders look like '<dongle>|<time>--0' exactly matching your route string","Fix data_dir to the directory that directly contains those segment folders (not one level up/down)","Re-copy the route from the device preserving the directory layout"],"exampleFix":"# before\nr = Route('b0c9d232|2022-01-01--00-00-00', data_dir='/data')\n\n# after\n# ensure /data/b0c9d232|2022-01-01--00-00-00--0/rlog.bz2 exists\nimport os\nassert any('--' in d for d in os.listdir('/data')), 'no segment dirs found'\nr = Route('b0c9d232|2022-01-01--00-00-00', data_dir='/data')","handlingStrategy":"validation","validationCode":"import os\n\ndef dir_has_segments(data_dir: str, route_name: str) -> bool:\n    return any(d.startswith(route_name + '--') for d in os.listdir(data_dir))","typeGuard":null,"tryCatchPattern":"try:\n    r = Route(name, data_dir=data_dir)\nexcept ValueError:\n    raise SystemExit(f'{data_dir} has no segments for {name}; check layout')","preventionTips":["Keep the canonical '<dongle>|<time>--<n>' folder layout when copying route data","Verify segment directories exist before constructing Route with data_dir","Route name must match folder names exactly (16-char dongle, 20-char timestamp)"],"tags":["route","local-data","filesystem","validation"],"backgroundTag":null,"analyzedSha":"516ec1e68203439a73f340f1d0b3b91eabc626ee","analyzedAt":"2026-08-15T00:17:37.461Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}