commaai/openpilot · error · ValueError
Could not find segments for route {self.name.canonical_name}
Error message
Could not find segments for route {self.name.canonical_name} in data directory {data_dir} What it means
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.
Source
Thrown at openpilot/tools/lib/route.py:163
try:
dcamera_path = next(path for path, filename in files if filename in FileName.DCAMERA)
except StopIteration:
dcamera_path = None
try:
ecamera_path = next(path for path, filename in files if filename in FileName.ECAMERA)
except StopIteration:
ecamera_path = None
try:
qcamera_path = next(path for path, filename in files if filename in FileName.QCAMERA)
except StopIteration:
qcamera_path = None
segments.append(Segment(segment, log_path, qlog_path, camera_path, dcamera_path, ecamera_path, qcamera_path))
if len(segments) == 0:
raise ValueError(f'Could not find segments for route {self.name.canonical_name} in data directory {data_dir}')
return sorted(segments, key=lambda seg: seg.name.segment_num)
class Segment:
def __init__(self, name, log_path, qlog_path, camera_path, dcamera_path, ecamera_path, qcamera_path):
self._events = None
self._name = SegmentName(name)
self.log_path = log_path
self.qlog_path = qlog_path
self.camera_path = camera_path
self.dcamera_path = dcamera_path
self.ecamera_path = ecamera_path
self.qcamera_path = qcamera_path
@property
def name(self):
return self._name
View on GitHub (pinned to 516ec1e682)
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
Example fix
# before
r = Route('b0c9d232|2022-01-01--00-00-00', data_dir='/data')
# after
# ensure /data/b0c9d232|2022-01-01--00-00-00--0/rlog.bz2 exists
import os
assert any('--' in d for d in os.listdir('/data')), 'no segment dirs found'
r = Route('b0c9d232|2022-01-01--00-00-00', data_dir='/data') Defensive patterns
Strategy: validation
Validate before calling
import os
def dir_has_segments(data_dir: str, route_name: str) -> bool:
return any(d.startswith(route_name + '--') for d in os.listdir(data_dir)) Try / catch
try:
r = Route(name, data_dir=data_dir)
except ValueError:
raise SystemExit(f'{data_dir} has no segments for {name}; check layout') Prevention
- 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)
When it happens
Trigger: 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.
Common situations: Pointing at an extracted-but-flattened dump; dongle ID or timestamp typo; data laid out for a different openpilot version's naming scheme.
Related errors
- Profile nickname must be 64 bytes or less
- Confirmation code required but not provided
- Invalid activation code format
- not a valid request or response
- -32000
AI-assisted analysis of commaai/openpilot@516ec1e682 (2026-08-15).
Data as JSON: /api/errors/19054b6d687e01bc.
Report an issue: GitHub.