Skip to content

EventStreamError if anon user key is empty string #209

@richardleggett

Description

@richardleggett

Describe the bug
After upgrading from release 3.1.5 to 4.2.0 we noticed that flags were no longer being synced for anonymous users, and LogCat shows:

Serializing object: {
  "timestamp": "2023-02-24T11:18:01.244Z",
  "message": {
      "message": "Encountered EventStream error connecting to URI: https://clientstream.launchdarkly.com/meval/eyJra...= - com.launchdarkly.eventsource.UnsuccessfulResponseException: Unsuccessful response code received from stream: 400"
    } ...
  }

To reproduce
Configure LD client with anon user, key is empty string:

private val ldConfig = LDConfig.Builder()
        .mobileKey(prodKey)
        .build()
        
private val anonUser = LDUser.Builder("")
        .anonymous(true)
        .build()
        
LDClient.init(applicationContext, ldConfig, anonUser, 5)

Expected behavior
Previously it would auto-generate or otherwise retrieve a GUID context key. Flags would be synced for anon users.

Actual behavior
No flags are synced (LD Client fails to connect to streaming).

Additional context
The workaround appears to be either:

  • Use a non-empty shared key: LDUser.Builder("anon")
  • Use the new LDConfig.Builder().generateAnonymousKeys(true)

The problem we had was that this was a "silent" breaking change, perhaps it should treat an empty string key as an invalid argument if it results in failing to connect to LD for streaming?

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