Repository navigation
Read a numeric zendesk_ticket_id in support bot conversations - #1744
Merged
Merged
Conversation
The server returns `zendesk_ticket_id` as a number once a conversation has a Zendesk ticket, which happens when the first message asks for a human. `BotConversation` expected a string, so creating such a conversation failed to parse: the ticket was created, but the apps showed an error, and each retry created another ticket. Keep the field an `Option<String>` and read it with `deserialize_string_or_integer_or_null`, so it accepts a number, a string or null without changing the Swift or Kotlin API.
Collaborator
XCFramework BuildThis PR's XCFramework is available for testing. Add to your .package(url: "https://github.com/automattic/wordpress-rs", branch: "pr-build/1744")Built from ead379f |
3 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes
BotConversationfailing to parse when the server returnszendesk_ticket_idas a number.Root Cause
zendesk_ticket_idisOption<String>, but once a conversation has a Zendesk ticket the server sends it as a number:A ticket is created as soon as the first message asks for a human, so
POST /odie/chat/<bot_id>fails for exactly that case. The conversation and its ticket are created on the server, but the apps show the error and give the message back, and each retry creates another ticket. Asking for a human later in a conversation isn't affected: replies go through/mobile-support/unified-conversations, whose model has no ticket field.All 10 conversations with a ticket on the account I checked (
jetpack-workflow-chat_mobile_support, back to 2026-10-28) return a number; conversations without one returnnull. The existing fixtures all havenull, so the tests never covered it.Both apps use this endpoint for the first message: WordPress-iOS (wordpress-rs 0.9.1) and WordPress-Android (0.10.0).
Fix
wp_api/src/wp_com/support_bots.rs: readzendesk_ticket_idwith the existingdeserialize_string_or_integer_or_null. It staysOption<String>, so the Swift and Kotlin API doesn't change, and it still reads a string ornull.create-conversation-response-with-ticket.json: the minimal-sources fixture with"zendesk_ticket_id": 12345678.Test plan
cargo test -p wp_api --lib support_bots: 14 passed. Without the fix,test_bot_create_conversation_with_zendesk_ticket_deserializationand the number case oftest_bot_conversation_zendesk_ticket_id_deserializationfail with the sameinvalid type: integererror.