# TypeError: Cannot read properties of undefined (reading 'forEach')

**URL:** <https://support.prodi.gy/t/typeerror-cannot-read-properties-of-undefined-reading-foreach/5966>\
**Category:** Uncategorized\
**Tags:** front-end, review\
**Created:** [September 23, 2022, 1:39pm UTC](https://support.prodi.gy/t/typeerror-cannot-read-properties-of-undefined-reading-foreach/5966 "2022-09-23T13:39:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![adin786](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/adin786/32/3284_2.png) [@adin786](https://support.prodi.gy/u/adin786)\
**Post date:** [September 23, 2022, 1:39pm UTC](https://support.prodi.gy/t/typeerror-cannot-read-properties-of-undefined-reading-foreach/5966/1 "2022-09-23T13:39:00Z")

</div>

Hi, I'm trying to run the built in `review` recipe on my annotated dataset. Unfortunately I'm getting an error on the web-app: `TypeError: Cannot read properties of undefined (reading 'forEach')`.

Here is the screenshot:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/prodigy/original/2X/d/d0d56bf9eb558b253ca42b2f653bd59c7d94b34d.png)

This is the fairly standard looking command I'm running to launch the prodigy server:

```python
prodigy review reviewed_test sents_sdr_cat --auto-accept

```

`PRODIGY_LOGGING=basic` doesn't give me any errors related to this, only the UI.

It seems to be that enabling `--auto-accept` is what causes this error as the recipe works fine when I disable that option. Of course, it massively speeds up the review process to not have to click through all the non-conflicting annotations, so that option seems quite useful. For info, the dataset was generated using a slight adaptation of the `textcat.correct` recipe from the [Github](https://github.com/explosion/prodigy-recipes). Thanks.

---

<div class="post-metadata">

**Author:** ![ryanwesslen](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/ryanwesslen/32/2969_2.png) [@ryanwesslen](https://support.prodi.gy/u/ryanwesslen)\
**Post date:** [September 23, 2022, 2:24pm UTC](https://support.prodi.gy/t/typeerror-cannot-read-properties-of-undefined-reading-foreach/5966/2 "2022-09-23T14:24:47Z")

</div>

hi @adin786!

Thanks for the information and welcome to the Prodigy community 👋

You may have found a bug. We really appreciate the info.

Could you provide 1 example of a record from your database so I can try to recreate on my end? I suspect it'll be standard for the [`classification` UI format](https://prodi.gy/docs/api-interfaces#classification), but I want to be sure.

You can provide the example like this:

```python
from prodigy.components.db import connect

db = connect()
examples = db.get_dataset("my_dataset")
examples[0] # if first record is causing this issue

```

Feel free to change the example if there are any proprietary details in your example.

We'll try to provide an update later next week if we're able to confirm it's a bug or if we can find a solution.

---

<div class="post-metadata">

**Author:** ![adin786](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/adin786/32/3284_2.png) [@adin786](https://support.prodi.gy/u/adin786)\
**Post date:** [September 26, 2022, 9:55am UTC](https://support.prodi.gy/t/typeerror-cannot-read-properties-of-undefined-reading-foreach/5966/3 "2022-09-26T09:55:39Z")

</div>

Hi Ryan,

Thanks for the very quick response! I did a bit of further digging on my side and I think it's in-fact not related to the `--auto-accept` option, instead due to a quirk of my dataset (but one that prodigy should perhaps handle more gracefully).

I think it's due to the following:

- When setting up my annotation task I started with using the built-in recipe for`textcat.manual`
- We annotated some examples, then trained a model and continued from there with the `textcat.correct` recipe.
  - ...except I had to use a custom version of `textcat.correct` from the [github examples page](https://github.com/explosion/prodigy-recipes/blob/master/textcat/textcat_correct.py) (I think it was because we needed to support active learning with **multiple labels** , which the built-in recipe doesn't do).

- It seems this github version of `textcat.correct` records an additional output field. I see this in the `.jsonl` filewhen I do `prodigy db-out` and when I output the data with your script Ryan.
  - It looks like `"config":{"choice_style":"multiple"}` is present in some of my examples, but not in others. I assume this is because the built-in recipe did not include that field by default.

- It looks like the web-app falls over when it sees duplicate entries like this (for which I would want to review). One with and one without the above field included.

I uploaded an example `debug.jsonl` file with the above quirk and you should be able to reproduce the error with the below. For info I'm on Prodigy `1.11.8`:

```bash
# Import to a dummy dataset
prodigy db-in debug_data ./debug.jsonl

# Launch the annotation server with the review 'recipe'
prodigy review debug_review debug_data

```

[debug.jsonl](https://support.prodi.gy/uploads/short-url/gliBfgROyQ7PczfaUPCsVF9z6wB.jsonl) (802 Bytes)

---

<div class="post-metadata">

**Author:** ![ryanwesslen](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/ryanwesslen/32/2969_2.png) [@ryanwesslen](https://support.prodi.gy/u/ryanwesslen)\
**Post date:** [February 3, 2023, 9:16pm UTC](https://support.prodi.gy/t/typeerror-cannot-read-properties-of-undefined-reading-foreach/5966/4 "2023-02-03T21:16:38Z")

</div>

hi @adin786!

I apologize for the delayed response.

> [@adin786](#):
>
> It looks like `"config":{"choice_style":"multiple"}, accept=[],` is present in some of my examples, but not in others. I assume this is because the built-in recipe did not include that field by default.

After some testing, yes, it looks like the problem are the records that don't include: `"config":{"choice_style":"multiple"}, accept=[],`.

I wasn't able to get into the front-end in depth, but as a work-around, could you simply add this to all of the records that don't have it?

After I did that, I didn't have an issue:

 ![localhost_8080_ (21)](https://us1.discourse-cdn.com/flex020/uploads/prodigy/original/2X/3/30636d2143cee955dd445d3efb3972992c8268b9.png)

[debug-corrected.jsonl](https://support.prodi.gy/uploads/short-url/mrFurKuSXcjpEtGuCTK4klKiTyf.jsonl) (855 Bytes)

Let us know if you have any further questions!
