Skip to content


Cannot parse recursive structure #5

jnunemaker opened this Issue · 1 comment

1 participant


The following code gives a ‘stack level too deep’ error message when run on the attached data file:

require ‘rubygems’ require ‘happymapper’ class Node include HappyMapper element :node_name, String has_many :node, ::Node end class Taxonomy include HappyMapper element :taxonomy_name, String has_many :node, ::Node end class Taxonomies include HappyMapper has_many :taxonomy, ::Taxonomy end file_contents =‘worldguide_data/taxonomy_short.xml’) taxonomies = Taxonomies.parse(file_contents) /opt/local/lib/ruby/gems/1.8/gems/jnunemaker-happymapper-0.1.5/lib/happymapper.rb:93:in `create_collection’: stack level too deep (SystemStackError) from /opt/local/lib/ruby/gems/1.8/gems/jnunemaker-happymapper-0.1.5/lib/happymapper.rb:93:in `each’ from /opt/local/lib/ruby/gems/1.8/gems/jnunemaker-happymapper-0.1.5/lib/happymapper.rb:93:in `create_collection’ from /opt/local/lib/ruby/gems/1.8/gems/jnunemaker-happymapper-0.1.5/lib/happymapper.rb:107:in `inject’ from /opt/local/lib/ruby/gems/1.8/gems/jnunemaker-happymapper-0.1.5/lib/happymapper.rb:90:in `each’ from /opt/local/lib/ruby/gems/1.8/gems/jnunemaker-happymapper-0.1.5/lib/happymapper.rb:90:in `inject’ from /opt/local/lib/ruby/gems/1.8/gems/jnunemaker-happymapper-0.1.5/lib/happymapper.rb:90:in `create_collection’ from /opt/local/lib/ruby/gems/1.8/gems/jnunemaker-happymapper-0.1.5/lib/happymapper.rb:79:in `parse’ from /opt/local/lib/ruby/gems/1.8/gems/jnunemaker-happymapper-0.1.5/lib/happymapper/item.rb:29:in `from_xml_node’ … 12965 levels… from /opt/local/lib/ruby/gems/1.8/gems/jnunemaker-happymapper-0.1.5/lib/happymapper.rb:90:in `inject’ from /opt/local/lib/ruby/gems/1.8/gems/jnunemaker-happymapper-0.1.5/lib/happymapper.rb:90:in `create_collection’ from /opt/local/lib/ruby/gems/1.8/gems/jnunemaker-happymapper-0.1.5/lib/happymapper.rb:79:in `parse’ from test.rb:22

From Mike Woodhouse (at old lighthouse project):

I tried that with 0.1.6 and didn’t get the error, which was good.

Recursive structures still don’t work properly, though: in Steve’s example, the Taxonomy object gets 4 Nodes: the single “parent” one and the three “children”. The parent does also get the children as you’d expect.

I’d already found this trying to write a script to play with my Google Reader OPML, which has some recursion of elements. See , which shows where I was able to work around the problem by removing higher-level outlines that had no children (which got the desired result in this particular case).

This issue was closed.
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.