Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Unknown alias: -624431998 (Psych::BadAlias) #135

Closed
bacancy-anand opened this Issue · 10 comments

7 participants

@bacancy-anand

Hi I am developing application with Cucumber Testing. I have used VCR to record request and response. I am facing error sometime when I run cucumber test. Here is the stack trace:

Unknown alias: -624431998 (Psych::BadAlias)
/home/anand/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:246:in
block in visit_Psych_Nodes_Alias'
/home/anand/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:246:in fetch'
/home/anand/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:246:in
visit_Psych_Nodes_Alias'
/home/anand/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/1.9.1/psych/visitors/visitor.rb:15:in visit'
/home/anand/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/1.9.1/psych/visitors/visitor.rb:5:in
accept'
/home/anand/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:20:in accept'
/home/anand/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:283:in
block in revive'
/home/anand/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:283:in map'
/home/anand/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:283:in
revive'
/home/anand/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:219:in visit_Psych_Nodes_Mapping'

But When I delete Cassatt and rerun the test feature, it works fine.

I want to know that why this error is coming and what should I do to remove this error permanently. Any suggestion would be appreciated. Thank you.

@jrafanie

I had issues like this in the past when YAML from 1.8.7 (syck) was not being loaded properly in 1.9.3 (psych). Check out the YAML cassette file and see if it's readable in 1.8.7 and 1.9.3. If possible, post the YAML file here.

You could also try the latest 1.9.3 version also.

@daveharris

Hi,
I have the same problem. See the yaml at https://gist.github.com/daveharris/ee30239620ed77c8a153#file-psych-unknown-alias-L1233

I get the error:

ActionView::Template::Error: Unknown alias: 70121654388580
    /Users/dave/.rbenv/versions/1.9.3-p385-perf/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:246:in `block in visit_Psych_Nodes_Alias'
    /Users/dave/.rbenv/versions/1.9.3-p385-perf/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:246:in `fetch'
    /Users/dave/.rbenv/versions/1.9.3-p385-perf/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:246:in `visit_Psych_Nodes_Alias'
    /Users/dave/.rbenv/versions/1.9.3-p385-perf/lib/ruby/1.9.1/psych/visitors/visitor.rb:15:in `visit'
    /Users/dave/.rbenv/versions/1.9.3-p385-perf/lib/ruby/1.9.1/psych/visitors/visitor.rb:5:in `accept'
    /Users/dave/.rbenv/versions/1.9.3-p385-perf/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:20:in `accept'
    /Users/dave/.rbenv/versions/1.9.3-p385-perf/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:283:in `block in revive'
    /Users/dave/.rbenv/versions/1.9.3-p385-perf/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:283:in `map'
    /Users/dave/.rbenv/versions/1.9.3-p385-perf/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:283:in `revive'
    /Users/dave/.rbenv/versions/1.9.3-p385-perf/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:219:in `visit_Psych_Nodes_Mapping'
...
    /Users/dave/.rbenv/versions/1.9.3-p385-perf/lib/ruby/1.9.1/psych.rb:128:in `load'
    /Users/dave/.rbenv/versions/1.9.3-p385-perf/lib/ruby/gems/1.9.1/gems/vcr-2.2.0/lib/vcr/cassette/serializers/yaml.rb:43:in `block in deserialize'
    /Users/dave/.rbenv/versions/1.9.3-p385-perf/lib/ruby/gems/1.9.1/gems/vcr-2.2.0/lib/vcr/cassette/serializers.rb:49:in `handle_encoding_errors'
    /Users/dave/.rbenv/versions/1.9.3-p385-perf/lib/ruby/gems/1.9.1/gems/vcr-2.2.0/lib/vcr/cassette/serializers/yaml.rb:42:in `deserialize'
    /Users/dave/.rbenv/versions/1.9.3-p385-perf/lib/ruby/gems/1.9.1/gems/vcr-2.2.0/lib/vcr/cassette.rb:248:in `deserialized_hash'
    /Users/dave/.rbenv/versions/1.9.3-p385-perf/lib/ruby/gems/1.9.1/gems/vcr-2.2.0/lib/vcr/cassette.rb:153:in `previously_recorded_interactions'
    /Users/dave/.rbenv/versions/1.9.3-p385-perf/lib/ruby/gems/1.9.1/gems/vcr-2.2.0/lib/vcr/cassette.rb:67:in `http_interactions'
    /Users/dave/.rbenv/versions/1.9.3-p385-perf/lib/ruby/gems/1.9.1/gems/vcr-2.2.0/lib/vcr.rb:273:in `http_interactions'
    /Users/dave/.rbenv/versions/1.9.3-p385-perf/lib/ruby/gems/1.9.1/gems/vcr-2.2.0/lib/vcr/request_handler.rb:75:in `stubbed_response'
    /Users/dave/.rbenv/versions/1.9.3-p385-perf/lib/ruby/gems/1.9.1/gems/vcr-2.2.0/lib/vcr/request_handler.rb:68:in `has_response_stub?'
    /Users/dave/.rbenv/versions/1.9.3-p385-perf/lib/ruby/gems/1.9.1/gems/vcr-2.2.0/lib/vcr/request_handler.rb:37:in `request_type'
    /Users/dave/.rbenv/versions/1.9.3-p385-perf/lib/ruby/gems/1.9.1/gems/vcr-2.2.0/lib/vcr/request_handler.rb:10:in `handle'
    /Users/dave/.rbenv/versions/1.9.3-p385-perf/lib/ruby/gems/1.9.1/gems/vcr-2.2.0/lib/vcr/library_hooks/webmock.rb:127:in `block in <module:WebMock>'
    /Users/dave/.rbenv/versions/1.9.3-p385-perf/lib/ruby/gems/1.9.1/gems/webmock-1.8.7/lib/webmock/stub_registry.rb:28:in `call'
    /Users/dave/.rbenv/versions/1.9.3-p385-perf/lib/ruby/gems/1.9.1/gems/webmock-1.8.7/lib/webmock/stub_registry.rb:28:in `block in register_global_stub'
    /Users/dave/.rbenv/versions/1.9.3-p385-perf/lib/ruby/gems/1.9.1/gems/webmock-1.8.7/lib/webmock/request_pattern.rb:34:in `call'
    /Users/dave/.rbenv/versions/1.9.3-p385-perf/lib/ruby/gems/1.9.1/gems/webmock-1.8.7/lib/webmock/request_pattern.rb:34:in `matches?'
    /Users/dave/.rbenv/versions/1.9.3-p385-perf/lib/ruby/gems/1.9.1/gems/webmock-1.8.7/lib/webmock/stub_registry.rb:52:in `block in request_stub_for'
    /Users/dave/.rbenv/versions/1.9.3-p385-perf/lib/ruby/gems/1.9.1/gems/webmock-1.8.7/lib/webmock/stub_registry.rb:51:in `each'
    /Users/dave/.rbenv/versions/1.9.3-p385-perf/lib/ruby/gems/1.9.1/gems/webmock-1.8.7/lib/webmock/stub_registry.rb:51:in `detect'
    /Users/dave/.rbenv/versions/1.9.3-p385-perf/lib/ruby/gems/1.9.1/gems/webmock-1.8.7/lib/webmock/stub_registry.rb:51:in `request_stub_for'
    /Users/dave/.rbenv/versions/1.9.3-p385-perf/lib/ruby/gems/1.9.1/gems/webmock-1.8.7/lib/webmock/stub_registry.rb:44:in `response_for_request'
    /Users/dave/.rbenv/versions/1.9.3-p385-perf/lib/ruby/gems/1.9.1/gems/webmock-1.8.7/lib/webmock/http_lib_adapters/net_http.rb:71:in `request_with_webmock'
    /Users/dave/.rbenv/versions/1.9.3-p385-perf/lib/ruby/gems/1.9.1/gems/rest-client-1.6.7/lib/restclient/request.rb:176:in `block in transmit'
    /Users/dave/.rbenv/versions/1.9.3-p385-perf/lib/ruby/gems/1.9.1/gems/webmock-1.8.7/lib/webmock/http_lib_adapters/net_http.rb:110:in `start_without_connect'
    /Users/dave/.rbenv/versions/1.9.3-p385-perf/lib/ruby/gems/1.9.1/gems/webmock-1.8.7/lib/webmock/http_lib_adapters/net_http.rb:123:in `start_with_conditional_connect'
    /Users/dave/.rbenv/versions/1.9.3-p385-perf/lib/ruby/gems/1.9.1/gems/rest-client-1.6.7/lib/restclient/request.rb:172:in `transmit'
    /Users/dave/.rbenv/versions/1.9.3-p385-perf/lib/ruby/gems/1.9.1/gems/rest-client-1.6.7/lib/restclient/request.rb:64:in `execute'
    /Users/dave/.rbenv/versions/1.9.3-p385-perf/lib/ruby/gems/1.9.1/gems/rest-client-1.6.7/lib/restclient/request.rb:33:in `execute'
    /Users/dave/.rbenv/versions/1.9.3-p385-perf/lib/ruby/gems/1.9.1/bundler/gems/dnz-client-0693ab4f9275/lib/dnz/request.rb:15:in `get'
    /Users/dave/.rbenv/versions/1.9.3-p385-perf/lib/ruby/gems/1.9.1/bundler/gems/dnz-client-0693ab4f9275/lib/dnz/user_set_relation.rb:59:in `sets_response'
    /Users/dave/.rbenv/versions/1.9.3-p385-perf/lib/ruby/gems/1.9.1/bundler/gems/dnz-client-0693ab4f9275/lib/dnz/user_set_relation.rb:33:in `fetch_sets'
    /Users/dave/.rbenv/versions/1.9.3-p385-perf/lib/ruby/gems/1.9.1/bundler/gems/dnz-client-0693ab4f9275/lib/dnz/user_set_relation.rb:25:in `sets'
    /Users/dave/.rbenv/versions/1.9.3-p385-perf/lib/ruby/gems/1.9.1/bundler/gems/dnz-client-0693ab4f9275/lib/dnz/user_set_relation.rb:109:in `order'
    /Users/dave/code/dnz/www/app/models/member.rb:76:in `latest_sets'

The problem is coming from the call made on line 1233

When I try and manually use load_file it failed with the same error, but worked fine when I used parse_file:

Psych.load_file("file.yml")
=> Psych::BadAlias: Unknown alias: 70339328335580
    from /Users/dave/.rbenv/versions/1.9.3-p385-perf/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:246:in `block in visit_Psych_Nodes_Alias'
    from /Users/dave/.rbenv/versions/1.9.3-p385-perf/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:246:in `fetch'
Psych.parse_file("file.yml")
=> #<Psych::Nodes::Document

Any ideas anyone?

Thanks,
Dave

@jrafanie

@daveharris and @bacancy-anand, what ruby version generated the .yml files for VCR?

@jrafanie

Also, keep in mind the latest ruby 1.9.3 has Psych 1.3.4, which is now 8 months old:
https://github.com/ruby/ruby/blob/v1_9_3_392/ext/psych/lib/psych.rb#L96

It might be worthwhile trying the psych master branch as there have been many commits since 1.3.4:
v1.3.4...master

@daveharris

@jrafanie I am using ruby 1.9.3-p385 built using ruby-build & rbenv via homebrew. I have installed the performance tweaks from https://gist.github.com/stan/4769888

I can confirm that my Psych is at version 1.3.4.

I am pretty sure the problem is down to an encoding issue with VCR. The VCR cassette says the encoding is US-ASCII but I have a feeling that somewhere some UTF-8 is being returned.

I have semi-resolved the issue by configuring VCR to store as json rather than yaml, but intrigued to know what is wrong.

I will try updating Psych but I hear there is a bit of stuff I need to do to get bundler to work correctly with system installed gems. I will let you know

@bacancy-anand

@jrafanie : when I typeruby -v, it says this :ruby 1.9.3p286 (2012-10-12 revision 37165) [i686-linux]
but strange is when I try gem list psych it gives nothing in result. Would it resolve the problem if I install Psych gem ?

@l15n
Collaborator

The problem is probably line 597

body: *70121654388580

This line uses YAML's alias syntax, i.e. *token.

i.e. minimum case is this:

irb(main):002:0> YAML.load ("foo:\n  body: *70121654388580")
Psych::BadAlias: Unknown alias: 70121654388580

Therefore, this seems to be a problem with VCR's YAML output, so you should probably lodge a bug report with VCR.

@tenderlove tenderlove referenced this issue from a commit
@tenderlove * ext/psych/lib/psych/visitors/to_ruby.rb: correctly register
  self-referential strings. Fixes tenderlove/psych #135

* test/psych/test_string.rb: appropriate test.
0c82d6d
@tenderlove
Owner

Should be fixed in 0c82d6d

@tenderlove tenderlove closed this
@nmccready

Just for others.. I have seen this error with a bad database.yml file when using DataMapper. Somehow the yml file got changed. I reverted the yml back with git checkout and everything started working again.

@reneedv

I saw this issue with a database.yml file as well -> we had this line:

cucumber:
  <<: *test

once I took it out it worked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.