Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

to_json causes and error #555

Open
rhuberdeau opened this issue May 10, 2021 · 5 comments · May be fixed by #556
Open

to_json causes and error #555

rhuberdeau opened this issue May 10, 2021 · 5 comments · May be fixed by #556
Labels
status: waiting for feedback waiting for feedback from the submitter type: bug bug in the library

Comments

@rhuberdeau
Copy link

Issue Summary

Stack level too deep error when calling to_json on a response object

This is a duplicate of #423 which was closed due to "no activity"

Steps to Reproduce

  1. Call to_json on any instance of a class that inherits from Domain

@childish-sambino added a fix to the closed ticket which works for me if I add it to domain.rb

def as_json(*)
  @properties
end

Code Snippet

$twilio.api.account.messages.list.to_json
SystemStackError: stack level too deep
	from (irb):6

Technical details:

  • twilio-ruby version: 5.53.0
  • ruby version: 2.5.1
@JenniferMah
Copy link
Contributor

Hi @rhuberdeau Thanks for opening a new issue! Can you open a PR with the fix implemented?

@JenniferMah JenniferMah added status: waiting for feedback waiting for feedback from the submitter type: bug bug in the library labels May 11, 2021
@rhuberdeau
Copy link
Author

Hi @JenniferMah. I'd be happy to open a PR but I wasn't able to come up with a test that replicates the bug. From what I can tell this issue doesn't pop up until the gem is installed into a Rails app.

@shwetha-manvinkurke shwetha-manvinkurke added status: work in progress Twilio or the community is in the process of implementing and removed status: waiting for feedback waiting for feedback from the submitter labels May 15, 2021
@armiiller
Copy link

In case someone is coming here to find a fix: I found this response by @eshanholtz really helpful: #524 (comment)

You can use the following to get the raw http response:

@client = Twilio::REST::Client.new(ACCOUNT_SID, AUTH_TOKEN)
message = @client.messages.create(to: '+14434653403', from: '+17637032543', body: 'test')
puts @client.http_client.last_response # Stores the JSON payload response

@AsabuHere
Copy link
Contributor

@rhuberdeau Can you test this in latest version and see if this issue exists? I tried to reproduce this issue with the same steps mentioned above, but couldn't succeed. If the issue is still there, can you please provide the below information?

  • The machine you are using to test this
  • Approximate number of messages in the list you are trying to access

@AsabuHere AsabuHere added status: waiting for feedback waiting for feedback from the submitter and removed status: work in progress Twilio or the community is in the process of implementing labels Apr 13, 2023
@YaroslavSulyma
Copy link

@AsabuHere I have the same problem with to_json/as_json methods.
I use:

gem 'rails', '~> 7.0.6'
gem 'twilio-ruby', '~> 6.2.0'

Steps to reproduce (Twilio Video example):
Just create or fetch room:

@client = Twilio::REST::Client.new(ACCOUNT_SID, AUTH_TOKEN)
@room = @client.video.v1.rooms.create(type: 'go',unique_name: 'My First Video Room')
render json: {room: @room.as_json}

Result: SystemStackError: stack level too deep

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting for feedback waiting for feedback from the submitter type: bug bug in the library
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants