Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: allow returning none for generic bindings #1379

Merged
merged 21 commits into from
Apr 18, 2024

Conversation

hallvictoria
Copy link
Contributor

@hallvictoria hallvictoria commented Dec 11, 2023

Description

Currently, when a function is triggered, the worker expects a request body with the trigger. However, in the case of generic binding types like the Dapr Cron binding trigger, no data is sent with the trigger request. This causes the worker to crash with an exception AttributeError: 'NoneType' object has no attribute 'type'. This fix enables triggers to execute successfully even if the trigger calls the app without any request body.

As per 1391, implicit output is enabled for generic types. Therefore, function apps with generic bindings that are also returning None will face an error TypeError: unable to encode outgoing TypedData: unsupported type "<class 'azure_functions_worker.bindings.generic.GenericBinding'>" for Python type "NoneType". This changes the worker to allow this scenario.

Fixes #1316
Fixes #1479


PR information

  • The title of the PR is clear and informative.
  • There are a small number of commits, each of which has an informative message. This means that previously merged commits do not appear in the history of the PR. For information on cleaning up the commits in your pull request, see this page.
  • If applicable, the PR references the bug/issue that it fixes in the description.
  • New Unit tests were added for the changes made and CI is passing.

Quality of Code and Contribution Guidelines

Copy link

codecov bot commented Dec 11, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 85.46%. Comparing base (7de7724) to head (dff0911).
Report is 3 commits behind head on dev.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #1379      +/-   ##
==========================================
+ Coverage   85.44%   85.46%   +0.01%     
==========================================
  Files          35       35              
  Lines        1965     1967       +2     
  Branches      370      371       +1     
==========================================
+ Hits         1679     1681       +2     
  Misses        213      213              
  Partials       73       73              
Flag Coverage Δ
unittests 85.40% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@hallvictoria hallvictoria changed the title Allow nill data for generic bindings Allow nil data for generic bindings Dec 11, 2023
@hallvictoria hallvictoria marked this pull request as ready for review December 12, 2023 17:34
Copy link
Member

@vrdmr vrdmr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit; otherwise LGTM

azure_functions_worker/bindings/generic.py Show resolved Hide resolved
@codecov-commenter
Copy link

codecov-commenter commented Mar 27, 2024

Codecov Report

Attention: Patch coverage is 75.00000% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 85.12%. Comparing base (330783f) to head (40c105b).
Report is 5 commits behind head on dev.

❗ Current head 40c105b differs from pull request most recent head ca87969. Consider uploading reports for the commit ca87969 to get more accurate results

Files Patch % Lines
azure_functions_worker/bindings/generic.py 66.66% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #1379      +/-   ##
==========================================
+ Coverage   84.64%   85.12%   +0.48%     
==========================================
  Files          35       35              
  Lines        2052     2004      -48     
  Branches      387      381       -6     
==========================================
- Hits         1737     1706      -31     
+ Misses        232      223       -9     
+ Partials       83       75       -8     
Flag Coverage Δ
unittests 85.07% <75.00%> (+0.47%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@hallvictoria hallvictoria changed the title Allow nil data for generic bindings fix: allow returning none for generic bindings Apr 18, 2024
@gavin-aguiar gavin-aguiar merged commit a754e58 into dev Apr 18, 2024
50 of 52 checks passed
@gavin-aguiar gavin-aguiar deleted the hallvictoria/allow-nill-data branch April 18, 2024 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants