Skip to content

Calls to Flags API do not respond with server flags when using a custom user agent #42731

@s6nedwards

Description

@s6nedwards

Bug Description

Custom user agents do not return server flags unless that user agent is mocking a known such as curl. This is annoying as it forces languages that do not have an official SDK to pretend to be a different library/client.

How to reproduce

Using curl make a request without a setting a custom user agent. Curl sets its own User Agent and thats recognized by Posthog.

curl https://us.i.posthog.com/flags/?v=2 \
    -X POST \
    -H 'Content-Type: application/json' \
    -d '{
    "api_key": "[API_KEY]",
    "distinct_id": "[user distinct id]"
}'

This will return server flags.
Now set a custom user agent

curl https://us.i.posthog.com/flags/?v=2 \
    -X POST \
    -H 'Content-Type: application/json' \
    -H 'User-Agent: this-is-not-accepted' \
    -d '{
    "api_key": "[API_KEY]",
    "distinct_id": "[user distinct id]"
}'

This will only return flags marked for all environments.

Additional context

Debug info

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working right

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions