Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion js/examples/nextjs/app/ui.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export function DemoClient(): ReactElement {
const [useStagingConnectBaseUrl, setUseStagingConnectBaseUrl] =
useState(false);
const [isConnectUrlTooltipOpen, setIsConnectUrlTooltipOpen] = useState(false);
const [worldIdVersion, setWorldIdVersion] = useState<"3.0" | "4.0">("3.0");
const [worldIdVersion, setWorldIdVersion] = useState<"3.0" | "4.0">("4.0");
const [v4CredentialType, setV4CredentialType] =
useState<V4CredentialType>("proof_of_human");
const [presetKind, setPresetKind] = useState<PresetKind>("orb");
Expand Down
8 changes: 7 additions & 1 deletion rust/core/src/bridge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,13 @@ impl BridgeConnection {
#[cfg(not(feature = "native-crypto"))]
let plaintext = decrypt(&self.key_bytes, &iv, &ciphertext)?;

let bridge_response: BridgeResponse = serde_json::from_slice(&plaintext)?;
let bridge_response: BridgeResponse =
serde_json::from_slice(&plaintext).map_err(|_| {
let raw = String::from_utf8_lossy(&plaintext);
Error::BridgeError(format!(
"World App returned an unrecognized response. This may indicate a version mismatch. Raw response: {raw}"
))
Comment on lines +640 to +644
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Classify unparseable bridge payloads as unexpected responses

This change maps JSON decode failures to Error::BridgeError, which downstream is treated as AppError::ConnectionFailed and a retryable NetworkingError (to_app_error/is_networking_error). For malformed or version-mismatched decrypted payloads, clients now mis-handle a protocol/format problem as a transport failure, which can trigger unnecessary retry loops and hide the real failure class. Keep the richer message if needed, but return an UnexpectedResponse/JSON-class error instead of BridgeError.

Useful? React with 👍 / 👎.

})?;

match bridge_response {
BridgeResponse::Error { error_code } => Ok(Status::Failed(error_code)),
Expand Down
Loading