Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fixtures YAML Exception Handing is Incorrect #2645

Closed
cfis opened this Issue · 4 comments

2 participants

@cfis

Around line 720 in activerecord/lib/active_record/fixtures.rb:

def parse_yaml_string(fixture_content)
YAML::load(erb_render(fixture_content))
rescue error
...
end

That should be a rescue Exception => error since a psych syntax error inherits from a e_rbSyntaxError and thus is not a StandardException and won't get caught.

@tenderlove
Owner

I don't think that code exists anymore. Are you looking at 3.0? 3.1?

@tenderlove tenderlove was assigned
@cfis

Still there, I'm using 3.1.0.rc6.

Full method starts at line 718 in fixtures.rb (activerecord/lib/active_record/fixtures.rb).

def parse_yaml_string(fixture_content)
YAML::load(erb_render(fixture_content))
rescue => error
raise Fixture::FormatError, "a YAML error occurred parsing #{yaml_file_path}. Please note that YAML must be consistently indented using spaces. Tabs are not allowed. Please have a look at http://www.yaml.org/faq.html\nThe exact error was:\n #{error.class}: #{error}"
end

Happy to send a pull request if that makes your life easier.

Thanks - Charlie

@tenderlove
Owner

Ah, okay. I will remove this exception handling. We may as well let the real parse error bubble up.

@cfis

The downside of removing the block is the default error doesn't tell you what fixture file is being parsed (which is why I noticed this in the first place). You just get a message "Invalid syntax at line 116, column 8". With lots of fixtures, that's not very helpful.

@tenderlove tenderlove closed this in f2aa46b
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.