# How to fix the error "TypeError: Cannot use 'in' operator to search for 'reject' in undefined" for my multi-question recipe?

**URL:** <https://support.prodi.gy/t/how-to-fix-the-error-typeerror-cannot-use-in-operator-to-search-for-reject-in-undefined-for-my-multi-question-recipe/7421>\
**Category:** Uncategorized\
**Tags:** solved\
**Created:** [October 24, 2024, 5:11pm UTC](https://support.prodi.gy/t/how-to-fix-the-error-typeerror-cannot-use-in-operator-to-search-for-reject-in-undefined-for-my-multi-question-recipe/7421 "2024-10-24T17:11:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![arya75](https://avatars.discourse-cdn.com/v4/letter/a/53a042/32.png) [@arya75](https://support.prodi.gy/u/arya75)\
**Post date:** [October 24, 2024, 5:11pm UTC](https://support.prodi.gy/t/how-to-fix-the-error-typeerror-cannot-use-in-operator-to-search-for-reject-in-undefined-for-my-multi-question-recipe/7421/1 "2024-10-24T17:11:58Z")

</div>

I have been trying to use the following recipe .py file to set up a multi-question annotation task. Although I don't face an error on terminal and the local host address is generated, when I open my localhost I keep seeing the error in the attached image. Does anyone know how to resolve this error "TypeError: Cannot use 'in' operator to search for 'reject' in undefined"? Thank you so much

Here is the recipe.py file:

```python
import prodigy
from prodigy.components.loaders import JSONL

@prodigy.recipe(
    "multi_question",
    dataset=("The dataset to save annotations", "positional", None, str),
    file_path=("Path to the JSONL data", "positional", None, str),
)
def multi_question(dataset, file_path):
    # Load the data from the JSONL file
    stream = JSONL(file_path)
    
    return {
        "dataset": dataset, # The dataset to save annotations
        "view_id": "blocks", # Use "blocks" to combine multiple interfaces
        "stream": stream, # Stream the data from the JSONL file
        "config": {
            "blocks": [
                {
                    "view_id": "text", # Show the text first
                    "text_field": "text"
                },
                {
                    "view_id": "choice", # The first question is a multiple choice
                    "question": "What is the sentiment of this text?",
                    "choices": [
                        {"id": "positive", "label": "Positive"},
                        {"id": "neutral", "label": "Neutral"},
                        {"id": "negative", "label": "Negative"}
                    ]
                },
                {
                    "view_id": "choice", # The second question, also multiple choice
                    "question": "Is this a question or a statement?",
                    "choices": [
                        {"id": "question", "label": "Question"},
                        {"id": "statement", "label": "Statement"}
                    ]
                },
                {
                    "view_id": "text_input", # Third question for free-form text input
                    "question": "Any additional comments?",
                    "field_rows": 3 # Number of rows for the input field
                }
            ]
        }
    }

```

Here is the error I see:

 ![Screen Shot 2024-10-24 at 1.09.11 PM](https://us1.discourse-cdn.com/flex020/uploads/prodigy/original/2X/9/9ec329bdd1704b686aef2266f1bfc9fae5495043.png)

---

<div class="post-metadata">

**Author:** ![magdaaniol](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/magdaaniol/32/2787_2.png) [@magdaaniol](https://support.prodi.gy/u/magdaaniol)\
**Post date:** [October 28, 2024, 4:37pm UTC](https://support.prodi.gy/t/how-to-fix-the-error-typeerror-cannot-use-in-operator-to-search-for-reject-in-undefined-for-my-multi-question-recipe/7421/2 "2024-10-28T16:37:49Z")

</div>

Welcome to the forum @arya75 👋

I went ahead and formatted your `recipe.py` as a code snippet - I'm pretty sure you'll agree it helps readability 🙂

The problem is that that your defnition `blocks` contains arbitrary `keys` such as `question` or `choices`. For Prodigy to be able to render correctly the UI, the `blocks` defnition must use pre-defined keys. You can find all these keys documented in ["Annotation interfaces](https://prodi.gy/docs/api-interfaces)" section of out docs:

Here's the fixed version of your script:

```python
import prodigy
from prodigy.components.loaders import JSONL

@prodigy.recipe(
    "multi_question",
    dataset=("The dataset to save annotations", "positional", None, str),
    file_path=("Path to the JSONL data", "positional", None, str),
)
def multi_question(dataset, file_path):
    # Load the data from the JSONL file
    stream = JSONL(file_path)
    
    return {
        "dataset": dataset, # The dataset to save annotations
        "view_id": "blocks", # Use "blocks" to combine multiple interfaces
        "stream": stream, # Stream the data from the JSONL file
        "config": {
            "blocks": [
                {
                    "view_id": "text",
                    "text_field": "text"
                },
                {
                    "view_id": "choice",
                    "text": "What is the sentiment of this text?", # changed the key question -> text
                    "options": [ # changed the key choices -> options
                        {"id": "positive", "text": "Positive"}, # changed the key label -> text 
                        {"id": "neutral", "text": "Neutral"},
                        {"id": "negative", "text": "Negative"}
                    ]
                },
                {
                    "view_id": "choice", # The second question, also multiple choice
                    "text": "Is this a question or a statement?",
                    "options": [
                        {"id": "question", "text": "Question"},
                        {"id": "statement", "text": "Statement"}
                    ]
                },
                {
                    "view_id": "text_input", # Third question for free-form text input
                    "question": "Any additional comments?",
                    "field_rows": 3 # Number of rows for the input field
                }
            ]
        }
    }

```

That said, I admit that the error message is not helpful at all. As a matter of fact, we are currently implementing a better data validation procedures and errors that you can expect to be available in our next release.
