tauri-apps/tauri · error · DecodingError
Invalid channel ID from \(channelDef)
Error message
Invalid channel ID from \(channelDef)
What it means
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.
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.
Example fix
// before: building the channel string by hand
const channel = `__CHANNEL__:${myCustomId}`
// after: let Tauri create it
const channel = new Channel(handler) Defensive patterns
Strategy: validation
Validate before calling
function isValidChannelDef(def) {
return typeof def === 'string' && /^__CHANNEL__:\d+$/.test(def) && BigInt(def.split(':')[1]) <= 18446744073709551615n
} Type guard
const isChannelDef = (v) => typeof v === 'string' && /^__CHANNEL__:\d+$/.test(v)
Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- Invalid channel definition from \(channelDef)
- missing userInfo for Channel handler. This is a Tauri issue
- unexpected channel value $channelDef
- Arch specified by Xcode was invalid.
- failed to read missing addr file
AI-assisted analysis of tauri-apps/tauri@460ec35447 (2026-09-18).
Data as JSON: /api/errors/9b236b72c704c131.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tauri/mobile/ios-api/Sources/Tauri/Channel.swift:27
public class Channel: Decodable {
public let id: UInt64
let handler: (UInt64, String) -> Void
public required init(from decoder: Decoder) throws {
let container = try decoder.singleValueContainer()
let channelDef = try container.decode(String.self)
let components = channelDef.components(separatedBy: CHANNEL_PREFIX)
if components.count < 2 {
throw DecodingError.dataCorruptedError(
in: container,
debugDescription: "Invalid channel definition from \(channelDef)"
)
}
guard let channelId = UInt64(components[1]) else {
throw DecodingError.dataCorruptedError(
in: container,
debugDescription: "Invalid channel ID from \(channelDef)"
)
}
guard let handler = decoder.userInfo[channelDataKey] as? (UInt64, String) -> Void else {
throw DecodingError.dataCorruptedError(
in: container,
debugDescription: "missing userInfo for Channel handler. This is a Tauri issue"
)
}
self.id = channelId
self.handler = handler
}
func serialize(_ data: JsonValue) -> String {
do {View on GitHub (pinned to 460ec35447)