Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Batch 400 Status Code: "failed to parse request: expected value at line 1 column 1" #208

Open
gaelph opened this issue Oct 9, 2024 · 1 comment
Labels
question Further information is requested Waiting for feedback

Comments

@gaelph
Copy link

gaelph commented Oct 9, 2024

Version

3.12.7

Steps to Reproduce

  1. Trigger any event
  2. Wait for a request to /batch to be sent

Expected Result

A successful call with a 200 status code.

Actual Result

The request to the /batch route consistently fails with a 400 HTTP status code.
The body of the response is always the plain text string: "failed to parse request: expected value at line 1 column 1".
This fails to be parsed as JSON and no explicit error shows up in the logs.
No events are shown in Activity feed on website.

The SDK is configured as follow:

let config = PostHogConfig(
    apiKey: Constants.PosthogKey,
    host: "https://\(Constants.PosthogHost)"
)
config.debug = true
PostHogSDK.shared.setup(config)

where the PosthogHost is either eu.i.posthog.com or eu.posthog.com with the same result.

Logs in XCode look as follow:

[PostHog] Queued event 'Application Opened'. Depth: 14
[PostHog] Queued event 'Application Opened'. Depth: 15
[PostHog] Decide called successfully.
[PostHog] Queued event 'Application Backgrounded'. Depth: 16
[PostHog] Queued event '$screen'. Depth: 17
[PostHog] Queued event '$screen'. Depth: 18
[PostHog] Queued event 'Application Opened'. Depth: 19
[PostHog] Queued event 'Application Backgrounded'. Depth: 20
[PostHog] Sending batch of 20 events to PostHog
[PostHog] Queued event '$screen'. Depth: 21
[PostHog] Already flushing
[PostHog] Queued event 'Application Opened'. Depth: 22
[PostHog] Already flushing
[PostHog] Queued event 'Application Backgrounded'. Depth: 23
[PostHog] Already flushing
[PostHog] Queued event 'Application Opened'. Depth: 24
[PostHog] Already flushing
[PostHog] Error sending events to batch API: status: nil.
[PostHog] Completed!
[PostHog] Sending batch of 4 events to PostHog

I am aware of a previous similar issue (#103), however the date sent_at seems to be formatted correctly, so I am assuming this is a different issue.

@gaelph gaelph added the bug Something isn't working label Oct 9, 2024
@marandaneto
Copy link
Member

@gaelph host should be https://eu.i.posthog.com for EU.
I wonder if it's your network or something, is this on an emulator only or on a real device?
I just tested this on an emulator and everything worked fine.
Double check if Constants.PosthogKey and Constants.PosthogHost are correct?

@marandaneto marandaneto added question Further information is requested and removed bug Something isn't working labels Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested Waiting for feedback
Projects
None yet
Development

No branches or pull requests

3 participants