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

unicode type check #3211

Merged
merged 7 commits into from
Sep 14, 2024
Merged

unicode type check #3211

merged 7 commits into from
Sep 14, 2024

Conversation

nagworld9
Copy link
Contributor

Description

Issue #


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

Quality of Code and Contribution Guidelines

"""
if not isinstance(value, bool):
return True if isinstance(value, str) and value.lower() == "true" else default_val
return True if isinstance(value, (ustr, str)) and value.lower() == "true" else default_val
Copy link
Member

@narrieta narrieta Sep 13, 2024

Choose a reason for hiding this comment

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

Suggested change
return True if isinstance(value, (ustr, str)) and value.lower() == "true" else default_val
return True if value.lower() == ustr("true") else default_val

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Initial intention was protecting against non-string/non-boolean and use default otherwise value.lower() will raise an error and will not process the extension.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

is your intention we are ok break the extension in that case? non-string/boolean totally unacceptable?

"""
if not isinstance(value, bool):
return True if isinstance(value, str) and value.lower() == "true" else default_val
return True if isinstance(value, (ustr, str)) and value.lower() == "true" else default_val
Copy link
Member

Choose a reason for hiding this comment

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

need unit test

@@ -3527,6 +3527,23 @@ def test_handler_manifest_boolen_fields(self):
self.assertFalse(manifest.is_report_heartbeat())
self.assertFalse(manifest.supports_multiple_extensions())

def test_unicode_values_for_boolean_fields_in_handler_manifest(self):
handler_json = {
Copy link
Member

Choose a reason for hiding this comment

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

We should do this test loading the json from a file, which is what exposed the problem

Other similar tests should probably also be modified

Copy link

codecov bot commented Sep 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 72.32%. Comparing base (3aebcdd) to head (e958a76).
Report is 304 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3211      +/-   ##
===========================================
+ Coverage    71.97%   72.32%   +0.34%     
===========================================
  Files          103      114      +11     
  Lines        15692    16978    +1286     
  Branches      2486     2452      -34     
===========================================
+ Hits         11295    12280     +985     
- Misses        3881     4132     +251     
- Partials       516      566      +50     

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

@nagworld9 nagworld9 merged commit 365dc28 into Azure:develop Sep 14, 2024
11 checks passed
@nagworld9 nagworld9 deleted the fix-ustr branch September 14, 2024 01:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants