{"record":{"id":"64299117fc26a761","repo":"commaai/openpilot","slug":"setnickname-failed-with-status-0x-code-02x","errorCode":null,"errorMessage":"SetNickname failed with status 0x{code:02X}","messagePattern":"SetNickname failed with status 0x(.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"openpilot/common/esim/lpa.py","lineNumber":409,"sourceCode":"    return []\n  return [decode_struct(value, PROFILE) for tag, value in iter_tlv(list_ok) if tag == 0xE3]\n\n\ndef list_profiles(client: AtClient) -> list[dict]:\n  return decode_profiles(es10x_command(client, TAG_PROFILE_INFO_LIST.to_bytes(2, \"big\") + b\"\\x00\"))\n\n\ndef set_profile_nickname(client: AtClient, iccid: str, nickname: str) -> None:\n  nickname_bytes = nickname.encode(\"utf-8\")\n  if len(nickname_bytes) > 64:\n    raise ValueError(\"Profile nickname must be 64 bytes or less\")\n  content = encode_tlv(TAG_ICCID, string_to_tbcd(iccid)) + encode_tlv(0x90, nickname_bytes)\n  response = es10x_command(client, encode_tlv(TAG_SET_NICKNAME, content))\n  code = require_tag(require_tag(response, TAG_SET_NICKNAME, \"SetNicknameResponse\"), TAG_STATUS, \"SetNickname status\")[0]\n  if code == 0x01:\n    raise LPAError(f\"profile {iccid} not found\")\n  if code != 0x00:\n    raise RuntimeError(f\"SetNickname failed with status 0x{code:02X}\")\n\n\n# --- ES9P HTTP ---\n\ndef es9p_request(smdp_address: str, endpoint: str, payload: dict, error_prefix: str = \"Request\", session: requests.Session | None = None) -> dict:\n  url = f\"https://{smdp_address}/gsma/rsp2/es9plus/{endpoint}\"\n  headers = {\"User-Agent\": \"gsma-rsp-lpad\", \"X-Admin-Protocol\": \"gsma/rsp/v2.3.0\", \"Content-Type\": \"application/json\"}\n  http = session or requests\n  resp = http.post(url, json=payload, headers=headers, timeout=HTTP_TIMEOUT, verify=GSMA_CI_BUNDLE)\n  resp.raise_for_status()\n  if not resp.content:\n    return {}\n  data = resp.json()\n  if \"header\" in data and \"functionExecutionStatus\" in data[\"header\"]:\n    status = data[\"header\"][\"functionExecutionStatus\"]\n    if status.get(\"status\") == \"Failed\":\n      sd = status.get(\"statusCodeData\", {})\n      reason = sd.get(\"reasonCode\", \"unknown\")","sourceCodeStart":391,"sourceCodeEnd":427,"githubUrl":"https://github.com/commaai/openpilot/blob/516ec1e68203439a73f340f1d0b3b91eabc626ee/openpilot/common/esim/lpa.py#L391-L427","documentation":"set_profile_nickname() maps the eUICC's SetNickname status byte: 0x00 success, 0x01 not-found (separate error), anything else raises RuntimeError with the raw status code in hex. These residual codes are undefined/unclassified eUICC rejections — e.g. insufficient memory or eUICC-internal errors — that SGP.22 does not enumerate for this operation.","triggerScenarios":"The eUICC answers the nickname request with a status other than 0x00/0x01: eUICC memory pressure, nonstandard firmware returning vendor-specific codes, or a corrupted response whose status byte is garbage.","commonSituations":"Low-end or test eUICCs with partial SGP.22 implementations; eUICC in a bad state after a failed install; status byte misparsed because the TLV layout differs from expected.","solutions":["Retry once after reopening the ISD-R channel — transient eUICC states (catBusy-like) can produce nonzero statuses","Dump the raw response with DEBUG=1 and compare against the eUICC's SGP.22 version; treat unknown codes as firmware-specific","If persistent, power-cycle the modem/eUICC and retry the nickname update"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n  set_profile_nickname(client, iccid, name)\nexcept RuntimeError as e:\n  if 'SetNickname failed with status' in str(e):\n    client.channel = None\n    client.open_isdr()\n    set_profile_nickname(client, iccid, name)  # single retry after channel reset\n  else:\n    raise","preventionTips":["Capture the hex status in logs for carrier/firmware diagnosis","Retry once after an ISD-R reopen; persistent codes are firmware-specific","Keep eUICC memory pressure low (delete unused profiles)"],"tags":["esim","sgp22","euicc","status-code","python"],"backgroundTag":null,"analyzedSha":"516ec1e68203439a73f340f1d0b3b91eabc626ee","analyzedAt":"2026-08-15T00:17:37.461Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}