# Can I prevent infinite loops in formulae?

**URL:** <https://community.fibery.io/t/can-i-prevent-infinite-loops-in-formulae/6346>\
**Category:** Get Help\
**Created:** [July 2, 2024, 2:14pm UTC](https://community.fibery.io/t/can-i-prevent-infinite-loops-in-formulae/6346 "2024-07-02T14:14:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![HereBeBeasties](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/herebebeasties/32/5429_2.png) [@HereBeBeasties](https://community.fibery.io/u/HereBeBeasties)\
**Post date:** [July 2, 2024, 2:14pm UTC](https://community.fibery.io/t/can-i-prevent-infinite-loops-in-formulae/6346/1 "2024-07-02T14:14:25Z")

</div>

I’d like to sum all the story points on Task and their recursive child Tasks.

Occasionally people make loops in the parent chain (I’m slightly unsure how they are doing that, but they seem to - perhaps there’s a bug in the drag+drop hierarchical list editors that causes this?).

Is there any way to recover from this?  
At the moment Fibery complains that there is a loop and then disables the formula. It would be nice if:

- The error mentioned which entities this affects, so you can at least go and fix them and re-enable it.
- Fibery didn’t let you do this in the first place.
  - Might I be able to achieve this with an automation somehow?
  - I suspect that even if I did, the formula would re-calculate and get disabled before the automation ran?

Or can I make a formula that somehow detects such loops and makes the calculation work regardless? (I would need to add the entities to a set as I went and check it, or something.)

---

<div class="post-metadata">

**Author:** ![Chr1sG](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/chr1sg/32/3941_2.png) [@Chr1sG](https://community.fibery.io/u/Chr1sG)\
**Post date:** [July 2, 2024, 3:24pm UTC](https://community.fibery.io/t/can-i-prevent-infinite-loops-in-formulae/6346/2 "2024-07-02T15:24:14Z")

</div>

> [@HereBeBeasties](#):
>
> It would be nice if:  
> The error mentioned which entities this affects, so you can at least go and fix them and re-enable it.

Yeah, we want to make this, and other errors, easier to debug. Not sure when we’ll work on it.

> [@HereBeBeasties](#):
>
> It would be nice if:  
> Fibery didn’t let you do this in the first place.

It’s actually quite hard to do performantly, since [it would imply a potentially unlimited search through the relationship tree](https://community.fibery.io/t/recursive-groupby-in-lists-stop-working-as-expected/6197/7).

> [@HereBeBeasties](#):
>
> Or can I make a formula that somehow detects such loops and makes the calculation work regardless? (I would need to add the entities to a set as I went and check it, or something.)

I can’t think of a way of solving this using the existing Fibery capabilities.  
Maybe something will become possible if/when Fibery has a [union function](https://community.fibery.io/t/union-function-to-merge-multiple-collections-into-a-single-collections-field/5680) in formulas 🤔

---

<div class="post-metadata">

**Author:** ![Matt\_Blais](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/matt_blais/32/1464_2.png) [@Matt\_Blais](https://community.fibery.io/u/Matt_Blais)\
**Post date:** [July 3, 2024, 5:19pm UTC](https://community.fibery.io/t/can-i-prevent-infinite-loops-in-formulae/6346/3 "2024-07-03T17:19:35Z")

</div>

It’s certainly possible for some javascript to check for loops in linked entities, at least for a few thousand entities (memory and CPU will eventually be a limiting factor), but I’m not sure how/when you would want to run it.
