commaai/openpilot · error · RuntimeError
Invalid profileMetadata
Error message
Invalid profileMetadata
What it means
parse_metadata() raises this when the base64-decoded profileMetadata payload does not contain the TAG_PROFILE_METADATA TLV tag. The function expects an ASN.1 DER structure with a profileMetadata root; its absence means the input is not a valid GSMA profileMetadata blob.
Source
Thrown at openpilot/common/esim/lpa.py:601
if result is None:
raise RuntimeError("Profile installation failed: no result from eUICC")
if not result["success"] and result["errorReason"] is not None:
msg = BPP_ERROR_MESSAGES.get(result["errorReason"])
if not msg:
cmd_name = BPP_COMMAND_NAMES.get(result["bppCommandId"], f"unknown({result['bppCommandId']})")
err_name = BPP_ERROR_REASONS.get(result["errorReason"], f"unknown({result['errorReason']})")
msg = f"Profile installation failed at {cmd_name}: {err_name}"
raise RuntimeError(msg)
if not result["success"]:
raise RuntimeError("Profile installation failed: no result from eUICC")
return result
def parse_metadata(b64_metadata: str) -> dict:
root = find_tag(b64d(b64_metadata), TAG_PROFILE_METADATA)
if root is None:
raise RuntimeError("Invalid profileMetadata")
return decode_struct(root, PROFILE)
def cancel_session(client: AtClient, transaction_id: bytes, reason: int = 127) -> str:
content = encode_tlv(0x80, transaction_id) + encode_tlv(0x81, bytes([reason]))
response = es10x_command(client, encode_tlv(TAG_CANCEL_SESSION, content))
return b64e(response)
def parse_lpa_activation_code(activation_code: str) -> tuple[str, str]:
"""Parse 'LPA:1$smdp.example.com$MATCHING-ID' into (smdp_address, matching_id)."""
if not activation_code.startswith("LPA:"):
raise ValueError("Invalid activation code format")
parts = activation_code[4:].split("$")
if len(parts) != 3:
raise ValueError("Invalid activation code format")
return parts[1], parts[2]
View on GitHub (pinned to 516ec1e682)
Solutions
- Verify the input is the profileMetadata field of the ES9+ response, not another base64 blob
- Decode the base64 manually and inspect the TLV tags to confirm structure
- Check for base64 URL-safe vs standard alphabet or padding issues before parsing
Defensive patterns
Strategy: validation
Validate before calling
from openpilot.common.esim.lpa import find_tag, TAG_PROFILE_METADATA
from base64 import b64decode
def is_valid_metadata(b64: str) -> bool:
try:
return find_tag(b64decode(b64), TAG_PROFILE_METADATA) is not None
except Exception:
return False Try / catch
try:
meta = parse_metadata(b64)
except RuntimeError:
log.exception("bad profileMetadata from SM-DP+")
raise Prevention
- Only pass the profileMetadata field from ES9+ responses
- Validate base64 alphabet/padding before parsing
When it happens
Trigger: Calling parse_metadata(b64_metadata) with a base64 string that decodes without a TAG_PROFILE_METADATA element — e.g. passing an arbitrary server response field or corrupted base64.
Common situations: Feeding the wrong field from an SM-DP+ response into parse_metadata; base64 padding/URL-safe alphabet mismatch; truncated metadata from a flaky transfer.
Related errors
- Invalid smdpSigned2
- Missing {label or f'tag 0x{target:X}'}
- Invalid BoundProfilePackage
- Profile installation failed at {cmd_name}: {err_name}
- Invalid activation code format
AI-assisted analysis of commaai/openpilot@516ec1e682 (2026-08-15).
Data as JSON: /api/errors/34afd45e53c6e031.
Report an issue: GitHub.