Skip to content

Statsig backend returning invalid json format #29

@blaxter

Description

@blaxter

This has been happening for a few months, but since yesterday, it has been happening 100% of the time (when no updates are coming from Statsig). Which translates to a lot of spammy logs:

[2025-06-04 16:47:35,097] WARNING output_logger: Request to https://api.statsigcdn.com/v1/download_config_specs/secret-****.json?sinceTime=1749047678148 failed with error 'utf-8' codec can't decode byte 0x80 in position 2: invalid start byte
[2025-06-04 16:47:44,727] WARNING output_logger: Request to https://api.statsigcdn.com/v1/download_config_specs/secret-****.json?sinceTime=1749047678148 failed with error 'utf-8' codec can't decode byte 0x80 in position 2: invalid start byte
[2025-06-04 16:47:45,171] WARNING output_logger: Request to https://api.statsigcdn.com/v1/download_config_specs/secret-****.json?sinceTime=1749047678148 failed with error 'utf-8' codec can't decode byte 0x80 in position 2: invalid start byte
[2025-06-04 16:47:54,844] WARNING output_logger: Request to https://api.statsigcdn.com/v1/download_config_specs/secret-****.json?sinceTime=1749047678148 failed with error 'utf-8' codec can't decode byte 0x80 in position 2: invalid start byte
[2025-06-04 16:47:55,273] WARNING output_logger: Request to https://api.statsigcdn.com/v1/download_config_specs/secret-****.json?sinceTime=1749047678148 failed with error 'utf-8' codec can't decode byte 0x80 in position 2: invalid start byte
[2025-06-04 16:48:04,960] WARNING output_logger: Request to https://api.statsigcdn.com/v1/download_config_specs/secret-****.json?sinceTime=1749047678148 failed with error 'utf-8' codec can't decode byte 0x80 in position 2: invalid start byte
[2025-06-04 16:48:05,361] WARNING output_logger: Request to https://api.statsigcdn.com/v1/download_config_specs/secret-****.json?sinceTime=1749047678148 failed with error 'utf-8' codec can't decode byte 0x80 in position 2: invalid start byte

The syncs are working (probably because they are gzip responses).

I can reproduce this easily outside Statsig library (I've tried setting Content-Type/Accept/Content-Encoding headers, same result):

statsig_full_url = f"https://api.statsigcdn.com/v1/download_config_specs/{statsig_secret}.json?sinceTime=1749047678148"
requests.get(statsig_full_url, stream=True).raw.read()
> b'\x0b\n\x80{"has_updates":false}\x03'

Using .content instead of .raw handles the extra bytes

requests.get(statsig_full_url, stream=True).content
> b'{"has_updates":false}'

The current response crashes the parsing with ijson.kvitems. A way to fix this is using .content directly here but the real issue is in statsig's backend returning invalid json (maybe something related with grpc?)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions