Azure / Azure/azure-functions-host

Python function app: Attribute error context object has no attribute retry_context

Open
#8,217 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
2k
Forks
482
Avg merge
2d 12h
Merged PRs (30d)
38

Description

#### Check for a solution in the Azure portal
For issues in production, please check for a solution to common issues in the Azure portal before opening a bug. In the Azure portal, navigate to your function app, select `Diagnose and solve problems` from the left, and view relevant dashboards before opening your issue.

#### Investigative information

Please provide the following:

- Timestamp: 2022-03-08 05:13:40.815
- Function App version: ~4
- Function App name: notifications-hw
- Function name(s) (as appropriate): TestRetryHttpTrigger
- Invocation ID: d84ec5ac-6e18-41fe-9f02-8baf70a9d675
- Region: East US

#### Repro steps

Provide the steps required to reproduce the problem:

1. Add the function level retry policy in function.json file as shown in the following doc - https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-error-pages?tabs=python#fixed-delay-retry.
2. Below is my function.json
{
"scriptFile": "__init__.py",
"bindings": [
{
"authLevel": "function",
"type": "httpTrigger",
"direction": "in",
"name": "req",
"methods": [
"get",
"post"
]
},
{
"type": "http",
"direction": "out",
"name": "$return"
}
],
"retry": {
"strategy": "fixedDelay",
"maxRetryCount": 4,
"delayInterval": "00:00:10"
}
}

4. Add the below line in the begining of your function to log number of retries.
logging.log(f'Current retry count: {context.retry_context.retry_count}')

#### Expected behavior

Provide a description of the expected behavior.

- Function runs 3 times as defined in the retry policy.
- Function should have logged the number of retires info.
-

#### Actual behavior

Provide a description of the actual behavior observed.

- Function runs 3 times as expected but throw Attribute error context object has no attribute retry_context. while logging the number of retries.

#### Known workarounds

Provide a description of any known workarounds.

#### Related information

Provide any related information

* Programming language used - Python
* Links to source - Sames as given on the following link https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-error-pages?tabs=python#fixed-delay-retry
* Bindings used - http

Contributor guide

Open the contributing guide

Research direction

Start with the reported function.json retry configuration and the Python function named TestRetryHttpTrigger, then review the linked Azure Functions retry documentation and reproduce the AttributeError around context.retry_context. Trace how the Python context is created for the HTTP trigger and verify that retry information is available when the function logs the retry count.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, python
Domain
backend, cloud
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.