Repository navigation
fix: report the server's reason when it rejects messages - #112
Draft
rahul-mixpanel wants to merge 2 commits into
Draft
rahul-mixpanel wants to merge 2 commits into
rahul-mixpanel wants to merge 2 commits into
Conversation
Request verbose responses from /track, /engage and /groups so a rejection such as a missing token surfaces as "token, missing or empty" instead of the generic "they may be malformed" message. Plain "1" responses are still accepted, and the rejected batch is still attached to the exception. Related to #38 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
[Medium impact] The PR appears safe to merge. Reviews (2) · Last reviewed commit: "fix: keep cause when attaching batch; cl..." · Reviewed by Greptile |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
Related to #38
Problem
When
/track,/engageor/groupsrejects a batch,MixpanelAPIalways throwsMixpanelServerException("Server refused to accept messages, they may be malformed."). The SDK never asks the server why, so a missing or null token (or any other rejection) gives the same vague message.Fix
sendDatanow addsverbose=1to the request, the way the Python, Ruby and Go SDKs already do. The server then answers with{"status":0,"error":"token, missing or empty"}, and the exception message carries that reason:Compatibility:
verbose=1query parameter is added.1response is still accepted (e.g. a proxy that ignoresverbose), as is the verbose{"status":1}.MixpanelServerException, andgetBadDeliveryContents()still returns the rejected batch./importis unchanged; it has its own response handling.Checked against the live API with an empty token:
verbose=0returns0,verbose=1returns{"error":"token, missing or empty","status":0}(both HTTP 200)./engageand/groupswith an empty$tokenandverbose=1likewise return HTTP 200 with{"error":"$token, missing or empty","status":0}.Tests
testServerRejectionIncludesServerReason: local HTTP server that behaves like/track. Fails onmasterwith the old "may be malformed" message and passes with the fix.testServerAcceptsVerboseAndPlainSuccess: both success formats are accepted.🤖 Generated with Claude Code