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

Version#changeset raises a ArgumentError #88

Closed
igorbozato opened this issue Aug 31, 2011 · 10 comments
Closed

Version#changeset raises a ArgumentError #88

igorbozato opened this issue Aug 31, 2011 · 10 comments

Comments

@igorbozato
Copy link

syntax error on line 13, col 1: `'
/home/igorbozato/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/yaml.rb:133:in `load'
/home/igorbozato/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/yaml.rb:133:in `load'
paper_trail (2.2.9) lib/paper_trail/version.rb:87:in `changeset'
app/views/admin/actions/show.html.erb:45:in `_app_views_admin_actions_show_html_erb__306327435_43834300_0'
@airblade
Copy link
Collaborator

Please can you post the YAML in question?

@igorbozato
Copy link
Author

--- !map:ActiveSupport::HashWithIndifferentAccess last_sign_in_ip: - 200.205.205.178 - 186.200.37.235 last_sign_in_at: - 2011-08-23 13:41:41 Z - 2011-08-26 22:24:20 Z sign_in_count: - 159 - 160 current_sign_in_ip: - 186.200.37.235 - 200.205.205.178 c

@airblade
Copy link
Collaborator

Your YAML seems to be stripped of new lines. Is that correct?

@igorbozato
Copy link
Author

Sorry, I get it using a ERB page, that is from terminal:

ree-1.8.7-2011.03 :002 > version.object_changes
 => "--- !map:ActiveSupport::HashWithIndifferentAccess \nlast_sign_in_ip: \n- 200.205.205.178\n- 186.200.37.235\nlast_sign_in_at: \n- 2011-08-23 13:41:41 Z\n- 2011-08-26 22:24:20 Z\nsign_in_count: \n- 159\n- 160\ncurrent_sign_in_ip: \n- 186.200.37.235\n- 200.205.205.178\nc" 

@igorbozato
Copy link
Author

From the db console:

mysql> select object_changes from versions where id = 3347;
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| object_changes                                                                                                                                                                                                                                                  |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| --- !map:ActiveSupport::HashWithIndifferentAccess 
last_sign_in_ip: 
- 200.205.205.178
- 186.200.37.235
last_sign_in_at: 
- 2011-08-23 13:41:41 Z
- 2011-08-26 22:24:20 Z
sign_in_count: 
- 159
- 160
current_sign_in_ip: 
- 186.200.37.235
- 200.205.205.178
c |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

@airblade
Copy link
Collaborator

Thanks for those outputs.

The problem is the YAML engine fails to parse the YAML string (which it generated in the first place).

>> require 'active_support'
>> YAML::load "--- !map:ActiveSupport::HashWithIndifferentAccess \nlast_sign_in_ip: \n- 200.205.205.178\n- 186.200.37.235\nlast_sign_in_at: \n- 2011-08-23 13:41:41 Z\n- 2011-08-26 22:24:20 Z\nsign_in_count: \n- 159\n- 160\ncurrent_sign_in_ip: \n- 186.200.37.235\n- 200.205.205.178\nc"
ArgumentError: syntax error on line 13, col 1: `'
    from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/yaml.rb:133:in `load'
    from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/yaml.rb:133:in `load'
    from (irb):12

Unfortunately I have no idea why it fails.

@michaelstalker
Copy link

This may be a long shot, but I've had some problems with PaperTrail's compatibility with one of the YAML parsers out there. I switched from psych to syck (or the other way around), and that fixed my problem.

@michaelstalker
Copy link

As a follow-up, I had added this to my config/boot.rb file to fix the problem I had:

require 'yaml'
YAML::ENGINE.yamler = 'syck'

@airblade
Copy link
Collaborator

@mstalker Thanks for posting that.

@batter
Copy link
Collaborator

batter commented Jan 3, 2013

It appears as though the error being thrown is the result of an errant c character at the end of @igorbozato's YAML string. If you remove the c from the end of the string, and try this:

YAML::load "--- !map:ActiveSupport::HashWithIndifferentAccess \nlast_sign_in_ip: \n- 200.205.205.178\n- 186.200.37.235\nlast_sign_in_at: \n- 2011-08-23 13:41:41 Z\n- 2011-08-26 22:24:20 Z\nsign_in_count: \n- 159\n- 160\ncurrent_sign_in_ip: \n- 186.200.37.235\n- 200.205.205.178\n"

It seems to work fine (with both psych and syck as the parser). Not sure how that c character snuck in there, but I have a feeling this may have been accidental user error or something? At any rate I think it is safe to say that this is an unusual case because others do not seem to be encountering this regularly.

If anyone thinks there is something errant in the PaperTrail code that could have caused this, please let us know and I will try to do a deeper investigation to address this problem. I could see a case for potentially swapping in JSON for the default serializer instead of YAML at some point in the future (perhaps v3.0.0) due to the known confusion surrounding psych and syck with the current Ruby releases.

@batter batter closed this as completed Jan 3, 2013
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

No branches or pull requests

4 participants