Skip to content

Encoding::UndefinedConversionError in polling mode when values contain invalid UTF-8 sequences #90

@Manfred

Description

@Manfred

When the client is running in polling mode and any of the HTTP responses from Launch Darkly contain invalid UTF-8 characters it will throw an exception and return the default value for the variation. In our specific case it's a custom key containing a customer name with "\xE2\x80\x99" (apostrophe) in it somewhere.

Apparently this is a Faraday HTTP cache problem and it was previously mentioned in a PR:
#51 (comment)

Our current workaround is to set the serializer to Marshal:

require 'ldclient-rb/requestor'

module LaunchDarkly
  class Requestor
    def initialize(sdk_key, config)
      @sdk_key = sdk_key
      @config = config
      @client = Faraday.new do |builder|
        builder.use :http_cache, store: @config.cache_store, serializer: Marshal
        builder.adapter :net_http_persistent
      end
    end
  end
end

This problem exists in 2.2.7.

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