reform icon indicating copy to clipboard operation
reform copied to clipboard

"stack level too deep" for self-included forms

Open Tab10id opened this issue 9 years ago • 11 comments

Hello again.

I have another problem with my not-normal form:

lass PostCommitAction::ConditionGroupForm < Reform::Form
  include Reform::Form::ModelReflections

  model 'post_commit_action/condition_group'
  property :cond_type
  collection :condition_groups,
             form: PostCommitAction::ConditionGroupForm
end

I get "stack level too deep" when try to validate params. It appears even without filled nested form

Test application - https://github.com/Tab10id/reform_test_app

Tab10id avatar Jul 20 '15 14:07 Tab10id

That fails because you have a recursion: each condition_groups form has another condition_groups form. Did that work in 1.x?

apotonick avatar Jul 20 '15 15:07 apotonick

Sorry but this my first experience with reform and I don't know how that form would feel in reform 1.x. But why I can't do that? I getting tasks with self-joins pretty often. I think there should be something like that:

collection :condition_groups,
                form: PostCommitAction::ConditionGroupForm,
                lazy: true

If it is possible in reform architecture of course


Sorry for my English

Tab10id avatar Jul 21 '15 05:07 Tab10id

No problem, and your english is great.

You are right, this should be possible, and I actually know where the problem is and I want to fix that, too. This problem appeared with Reform 2.0, that's why I asked.

I will let you know if I make any progress.

apotonick avatar Jul 21 '15 07:07 apotonick

Please try that with Disposable-0.1.9 and close this issue if that got fixed for you. :fireworks: :smile:

apotonick avatar Jul 21 '15 10:07 apotonick

Sorry but stack level is still too deep=) https://github.com/Tab10id/reform_test_app updated

Tab10id avatar Jul 21 '15 11:07 Tab10id

I can't provoke this problem anymore, please prepare a minimal test file in your sample app. Thanks!

apotonick avatar Jul 21 '15 11:07 apotonick

Does that only happen when calling validate?

apotonick avatar Jul 21 '15 11:07 apotonick

Ah ok I think I know where the problem is. I have no idea how to fix this currently, sorry. The problem is that we compile the deserializer at run-time, which goes through the form's structure. In your case, you specify an infinite loop. How many levels does your form have? If it's only one, then your form declaration is wrong, anyway.

apotonick avatar Jul 21 '15 11:07 apotonick

Idea was about form with not-limited count of levels. I'll try to prepare app with that tests today. Hope that will work fine in future versions of reform. Anyway, thanks for a attempt of quick fix.

PS: Honestly I don't really need multilevel form in real project, it was just test of reform functionality=)

Tab10id avatar Jul 21 '15 13:07 Tab10id

Hahaha! :laughing: Wait, you don't need to prepare a test, I found out how to provoke that.

The thing is, "multilevel" is not a problem, you can have any kind of nesting, the only issue is the automatic inferral of the deserializing representer (which is something that shouldn't bother you!). I find this an interesting problem, and you've already helped me to improve Disposable so I am keen to make this feature possible. Thanks!!!! :beers:

apotonick avatar Jul 21 '15 13:07 apotonick

@apotonick is there any update on this? I bumped into it a while ago and took it as a warning shot to revisit what I was doing :) If there aren't plans to further this, and it's not a real issue for Tab10id then can we close?

fran-worley avatar Jul 07 '16 05:07 fran-worley