Skip to content

Client instance clobbers internal state #93

@jacobat

Description

@jacobat

Issue Summary

Reusing the Sendgrid client causes a 404.

Steps to Reproduce

If you try to reuse a client with a path multiple times it fails on subsequent attempts:

mail = SendGrid::Mail.new
[ ... do some mail setup ...]
client = SendGrid::API.new(api_key: API_KEY, host: 'https://api.sendgrid.com').client.mail
client._('send').post(request_body: mail.to_json) # This succeeds
client._('send').post(request_body: mail.to_json) # This fails

if instead you move the clients #mail method to be called twice things work:

mail = SendGrid::Mail.new
[ ... do some mail setup ...]
client = SendGrid::API.new(api_key: API_KEY, host: 'https://api.sendgrid.com').client
client.mail._('send').post(request_body: mail.to_json) # This succeeds
client.mail._('send').post(request_body: mail.to_json) # This succeeds

This is very unexpected behaviour, the code should not require you to call mail over an over. Instead you should be able to reuse the same client instance over and over.

Technical details:

  • ruby-http-client Version: 3.3.0
  • Ruby Version: 2.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    difficulty: mediumfix is medium in difficultystatus: work in progressTwilio or the community is in the process of implementingtype: bugbug in the library

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions