# Buggy code
async def evaluate_stories(request: Request, temporary_directory: Path) -> HTTPResponse:
    """Evaluate stories against the currently loaded model."""
    validate_request_body(
        request,
        "You must provide some stories in the request body in order to "
        "evaluate your model.",
    )

    test_data = _test_data_file_from_payload(request, temporary_directory)

    use_e2e = rasa.utils.endpoints.bool_arg(request, "e2e", default=False)

    try:
        evaluation = await test(
            test_data, app.agent, e2e=use_e2e, disable_plotting=True
        )
        return response.json(evaluation)
    except Exception as e:
        logger.error(traceback.format_exc())
        raise ErrorResponse(
            HTTPStatus.INTERNAL_SERVER_ERROR,
            "TestingError",
            f"An unexpected error occurred during evaluation. Error: {e}",
        )


# Traceback (ValueError)
{
"version": "2.0.0",
"status": "failure",
"message": "An unexpected error occurred during evaluation. Error: Unknown data format for file '/var/folders/7y/mgv9hfvs45l75j9mn_5gxv2h0000gr/T/tmp93blnen6.md'.",
"reason": "TestingError",
"details": {},
"help": null,
"code": 500
}

2020-10-19 15:48:44 ERROR    rasa.server  - Traceback (most recent call last):
File "/Users/rasa/.pyenv/versions/3.7.6/envs/rasa_376/lib/python3.7/site-packages/rasa/server.py", line 891, in evaluate_intents
evaluation = run_evaluation(data_path, nlu_model, disable_plotting=True)
File "/Users/rasa/.pyenv/versions/3.7.6/envs/rasa_376/lib/python3.7/site-packages/rasa/nlu/test.py", line 1476, in run_evaluation
data_path, interpreter.model_metadata.language
File "/Users/rasa/.pyenv/versions/3.7.6/envs/rasa_376/lib/python3.7/site-packages/rasa/shared/nlu/training_data/loading.py", line 60, in load_data
data_sets = [_load(f, language) for f in files]
File "/Users/rasa/.pyenv/versions/3.7.6/envs/rasa_376/lib/python3.7/site-packages/rasa/shared/nlu/training_data/loading.py", line 60, in <listcomp>
data_sets = [_load(f, language) for f in files]
File "/Users/rasa/.pyenv/versions/3.7.6/envs/rasa_376/lib/python3.7/site-packages/rasa/shared/nlu/training_data/loading.py", line 107, in _load
raise ValueError(f"Unknown data format for file '{filename}'.")
ValueError: Unknown data format for file '/var/folders/7y/mgv9hfvs45l75j9mn_5gxv2h0000gr/T/tmp93blnen6.md'.

2020-10-19 15:48:44 ERROR    rasa.server  - An unexpected error occurred during evaluation. Error: Unknown data format for file '/var/folders/7y/mgv9hfvs45l75j9mn_5gxv2h0000gr/T/tmp93blnen6.md'.

# Fixed code
async def evaluate_stories(request: Request, temporary_directory: Path) -> HTTPResponse:
    """Evaluate stories against the currently loaded model."""
    validate_request_body(
        request,
        "You must provide some stories in the request body in order to "
        "evaluate your model.",
    )

    test_data = _test_data_file_from_payload(request, temporary_directory, ".md")

    use_e2e = rasa.utils.endpoints.bool_arg(request, "e2e", default=False)

    try:
        evaluation = await test(
            test_data, app.agent, e2e=use_e2e, disable_plotting=True
        )
        return response.json(evaluation)
    except Exception as e:
        logger.error(traceback.format_exc())
        raise ErrorResponse(
            HTTPStatus.INTERNAL_SERVER_ERROR,
            "TestingError",
            f"An unexpected error occurred during evaluation. Error: {e}",
        )