{"record":{"id":"9b236b72c704c131","repo":"tauri-apps/tauri","slug":"invalid-channel-id-from-channeldef","errorCode":null,"errorMessage":"Invalid channel ID from \\(channelDef)","messagePattern":"Invalid channel ID from \\\\\\(channelDef\\)","errorType":"exception","errorClass":"DecodingError","httpStatus":null,"severity":"error","filePath":"crates/tauri/mobile/ios-api/Sources/Tauri/Channel.swift","lineNumber":27,"sourceCode":"\npublic class Channel: Decodable {\n  public let id: UInt64\n  let handler: (UInt64, String) -> Void\n\n  public required init(from decoder: Decoder) throws {\n    let container = try decoder.singleValueContainer()\n    let channelDef = try container.decode(String.self)\n\n    let components = channelDef.components(separatedBy: CHANNEL_PREFIX)\n    if components.count < 2 {\n      throw DecodingError.dataCorruptedError(\n        in: container,\n        debugDescription: \"Invalid channel definition from \\(channelDef)\"\n      )\n\n    }\n    guard let channelId = UInt64(components[1]) else {\n      throw DecodingError.dataCorruptedError(\n        in: container,\n        debugDescription: \"Invalid channel ID from \\(channelDef)\"\n      )\n    }\n\n    guard let handler = decoder.userInfo[channelDataKey] as? (UInt64, String) -> Void else {\n      throw DecodingError.dataCorruptedError(\n        in: container,\n        debugDescription: \"missing userInfo for Channel handler. This is a Tauri issue\"\n      )\n    }\n\n    self.id = channelId\n    self.handler = handler\n  }\n\n  func serialize(_ data: JsonValue) -> String {\n    do {","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/tauri-apps/tauri/blob/460ec35447493200d64290dd7f015d5a91d0fd58/crates/tauri/mobile/ios-api/Sources/Tauri/Channel.swift#L9-L45","documentation":"Tauri's iOS Channel initializer decodes a channel definition string of the form '<prefix><numeric-id>' (e.g. '__CHANNEL__:123'). The numeric portion could not be parsed as a UInt64, so DecodingError.dataCorruptedError is thrown with this message. It indicates the channel definition string passed through the IPC bridge was malformed or a different format than expected.","triggerScenarios":"Decoding a Channel from JSON where components[1] (the part after the channel prefix) is not a valid UInt64: non-numeric text, negative numbers, an ID exceeding UInt64 range, or a string missing the ID segment entirely.","commonSituations":"Mismatched channel-serialization formats between the Rust core and the iOS webview layer (e.g. after upgrading Tauri versions so prefix/format changed), custom plugins hand-rolling channel strings, or a corrupted/truncated IPC payload.","solutions":["Ensure the channel definition string is generated by Tauri's own channel machinery and includes a numeric ID after the prefix (e.g. __CHANNEL__:42).","Align the Rust and iOS Tauri versions so the channel wire format/prefix matches on both sides.","Log the received channelDef string to confirm the actual format being decoded.","Check custom plugin code for hand-built channel identifiers and replace them with Channel instances from the plugin API."],"exampleFix":"// before: building the channel string by hand\nconst channel = `__CHANNEL__:${myCustomId}`\n// after: let Tauri create it\nconst channel = new Channel(handler)","handlingStrategy":"validation","validationCode":"function isValidChannelDef(def) {\n  return typeof def === 'string' && /^__CHANNEL__:\\d+$/.test(def) && BigInt(def.split(':')[1]) <= 18446744073709551615n\n}","typeGuard":"const isChannelDef = (v) => typeof v === 'string' && /^__CHANNEL__:\\d+$/.test(v)","tryCatchPattern":null,"preventionTips":["Always create channels via the official Channel constructor/API, never via string concatenation.","Keep Rust and mobile runtime versions in sync.","Log raw channelDef payloads when debugging IPC issues."],"tags":["ios","decoding","ipc","channel","invalid-id"],"backgroundTag":"invalid-argument-format","analyzedSha":"460ec35447493200d64290dd7f015d5a91d0fd58","analyzedAt":"2026-09-18T23:55:51.277Z","contentChangedAt":"2026-09-18T23:55:51.277Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}