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

If Travis API is unavailable, gem throws FrozenError rather than a helpful message #753

Closed
dnwe opened this issue Jun 9, 2020 · 3 comments · Fixed by #754
Closed

If Travis API is unavailable, gem throws FrozenError rather than a helpful message #753

dnwe opened this issue Jun 9, 2020 · 3 comments · Fixed by #754

Comments

@dnwe
Copy link

dnwe commented Jun 9, 2020

By coincidence our Travis Enterprise endpoint was returning HTTP 500s for a period. However, from the Travis gem used in our automation this manifested as a "can't modify frozen Hash (FrozenError)" error rather than a helpful message showing that the problem was with the API rather than the CLI.

/ # ruby --version
ruby 2.5.8p224 (2020-03-31 revision 67882) [x86_64-linux-musl]

/ # travis --version
1.9.1

/ # travis endpoint --set-default -X --api-endpoint https://travis.example.com/api
can't modify frozen Hash

/ # travis endpoint -E --debug --debug-http --set-default -X --api-endpoint https://travis.example.com/api
** Loading "/home/example/.travis/config.yml"
Traceback (most recent call last):
        7: from /usr/bin/travis:23:in `<main>'
        6: from /usr/bin/travis:23:in `load'
        5: from /usr/lib/ruby/gems/2.5.0/gems/travis-1.9.1/bin/travis:18:in `<top (required)>'
        4: from /usr/lib/ruby/gems/2.5.0/gems/travis-1.9.1/lib/travis/cli.rb:64:in `run'
        3: from /usr/lib/ruby/gems/2.5.0/gems/travis-1.9.1/lib/travis/cli/command.rb:199:in `execute'
        2: from /usr/lib/ruby/gems/2.5.0/gems/travis-1.9.1/lib/travis/cli/api_command.rb:53:in `setup'
        1: from /usr/lib/ruby/gems/2.5.0/gems/travis-1.9.1/lib/travis/cli/api_command.rb:114:in `setup_enterprise'
/usr/lib/ruby/gems/2.5.0/gems/travis-1.9.1/lib/travis/cli/api_command.rb:114:in `delete': can't modify frozen Hash (FrozenError)

/ # curl -sS https://travis.example.com/api/
<html>
<head><title>500 Internal Server Error</title></head>
<body>
<center><h1>500 Internal Server Error</h1></center>
<hr><center>nginx/1.16.1</center>
</body>
</html>
@dnwe
Copy link
Author

dnwe commented Jun 9, 2020

Hmm, maybe that HTTP 500 is a false positive actually, because calling absolute API calls via curl (e.g., https://travis.example.com/api/repo/orgname%2Freponame) is working. So perhaps the freeze error is unrelated to the API being up or down

@BanzaiMan
Copy link
Contributor

Does your travis installation have assets/cacert.pem?

# start with a normal installation; it works
travis@55375469c8f2:~$ travis endpoint -E --debug --debug-http --set-default -X --api-endpoint https://travis.example.com/api
** Loading "/home/travis/.travis/config.yml"
API endpoint: https://travis.example.com/api (stored as default)
** Storing "/home/travis/.travis/config.yml"
# confirm that cacert.pem exists at the correct location
travis@55375469c8f2:~$ ls $(dirname $(gem which travis))/../assets/cacert.pem
/home/travis/.rvm/gems/ruby-2.6.5/gems/travis-1.9.1/lib/../assets/cacert.pem
# move the file
travis@55375469c8f2:~$ mv $(dirname $(gem which travis))/../assets/cacert.pem .
# confirm the "frozen Hash" error
travis@55375469c8f2:~$ travis endpoint -E --debug --debug-http --set-default -X --api-endpoint https://travis.example.com/api
** Loading "/home/travis/.travis/config.yml"
Traceback (most recent call last):
        9: from /home/travis/.rvm/gems/ruby-2.6.5/bin/ruby_executable_hooks:24:in `<main>'
        8: from /home/travis/.rvm/gems/ruby-2.6.5/bin/ruby_executable_hooks:24:in `eval'
        7: from /home/travis/.rvm/gems/ruby-2.6.5/bin/travis:23:in `<main>'
        6: from /home/travis/.rvm/gems/ruby-2.6.5/bin/travis:23:in `load'
        5: from /home/travis/.rvm/gems/ruby-2.6.5/gems/travis-1.9.1/bin/travis:18:in `<top (required)>'
        4: from /home/travis/.rvm/gems/ruby-2.6.5/gems/travis-1.9.1/lib/travis/cli.rb:64:in `run'
        3: from /home/travis/.rvm/gems/ruby-2.6.5/gems/travis-1.9.1/lib/travis/cli/command.rb:199:in `execute'
        2: from /home/travis/.rvm/gems/ruby-2.6.5/gems/travis-1.9.1/lib/travis/cli/api_command.rb:53:in `setup'
        1: from /home/travis/.rvm/gems/ruby-2.6.5/gems/travis-1.9.1/lib/travis/cli/api_command.rb:114:in `setup_enterprise'
/home/travis/.rvm/gems/ruby-2.6.5/gems/travis-1.9.1/lib/travis/cli/api_command.rb:114:in `delete': can't modify frozen Hash (FrozenError)
# move cacert.pem back
travis@55375469c8f2:~$ mv cacert.pem $(dirname $(gem which travis))/../assets
# it works again
travis@55375469c8f2:~$ travis endpoint -E --debug --debug-http --set-default -X --api-endpoint https://travis.example.com/api
** Loading "/home/travis/.travis/config.yml"
API endpoint: https://travis.example.com/api (stored as default)
** Storing "/home/travis/.travis/config.yml"

If this is the case for you, a better error message is more helpful.

@curtcurt871
Copy link

#753

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants