Skip to content

URI.encode breaks the SDK on Ruby 3 #22

@alex-damian-negru

Description

@alex-damian-negru

What is the problem?

In Ruby 2.7, URI.encode is deprecated. In Ruby 3, it is removed, breaking the SDK.

NoMethodError:
  undefined method `encode' for URI:Module
      
        URI.encode(url)
           ^^^^^^^
# /usr/local/bundle/gems/mparticle-1.1.1/lib/mparticle/configuration.rb:139:in `base_url'
# /usr/local/bundle/gems/mparticle-1.1.1/lib/mparticle/api_client.rb:276:in `build_request_url'
# /usr/local/bundle/gems/mparticle-1.1.1/lib/mparticle/api_client.rb:111:in `build_request'
# /usr/local/bundle/gems/mparticle-1.1.1/lib/mparticle/api_client.rb:38:in `call_api'
# /usr/local/bundle/gems/mparticle-1.1.1/lib/mparticle/api/events_api.rb:101:in `upload_events'

Possible solutions

The official docs claim this:

This method is obsolete and should not be used. Instead, use CGI.escape, URI.encode_www_form or URI.encode_www_form_component depending on your specific use case.

There also seems to be an open PR that replaces URI.encode with Addressable::URI.encode. I tried it locally and my specs are passing, so that should also fix it.

Note: this issue has been opened to bring additional attention to the matter; although the fix mentioned above is open, it has been so for a month now without any response from an official maintainer..

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