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: TypeError: expected string or bytes-like object, got 'list' #319

Merged
merged 1 commit into from
Feb 5, 2024

Conversation

CM000n
Copy link
Collaborator

@CM000n CM000n commented Jan 27, 2024

sub expects a string for string masking, but currently it can receive any type. Therefore, we should convert the message into a string beforehand.

2024-01-27T21:12:43.276792243Z   File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 256, in _async_update_data
2024-01-27T21:12:43.276804451Z     return await self.update_method()
2024-01-27T21:12:43.276813478Z            ^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-01-27T21:12:43.276821534Z   File "/config/custom_components/toyota/__init__.py", line 102, in async_get_vehicle_data
2024-01-27T21:12:43.276830029Z     _LOGGER.debug(vehicle_informations)
2024-01-27T21:12:43.276837955Z   File "/usr/local/lib/python3.11/logging/__init__.py", line 1477, in debug
2024-01-27T21:12:43.276868291Z     self._log(DEBUG, msg, args, **kwargs)
2024-01-27T21:12:43.276877968Z   File "/usr/local/lib/python3.11/logging/__init__.py", line 1634, in _log
2024-01-27T21:12:43.276890185Z     self.handle(record)
2024-01-27T21:12:43.276902704Z   File "/usr/local/lib/python3.11/logging/__init__.py", line 1644, in handle
2024-01-27T21:12:43.276912209Z     self.callHandlers(record)
2024-01-27T21:12:43.276920238Z   File "/usr/local/lib/python3.11/logging/__init__.py", line 1706, in callHandlers
2024-01-27T21:12:43.276929011Z     hdlr.handle(record)
2024-01-27T21:12:43.276937179Z   File "/usr/local/lib/python3.11/logging/__init__.py", line 974, in handle
2024-01-27T21:12:43.276945496Z     rv = self.filter(record)
2024-01-27T21:12:43.276957643Z          ^^^^^^^^^^^^^^^^^^^
2024-01-27T21:12:43.276970582Z   File "/usr/local/lib/python3.11/logging/__init__.py", line 830, in filter
2024-01-27T21:12:43.276979936Z     result = f.filter(record)
2024-01-27T21:12:43.276987794Z              ^^^^^^^^^^^^^^^^
2024-01-27T21:12:43.276995922Z   File "/usr/local/lib/python3.11/site-packages/mytoyota/utils/logging/log_filters.py", line 16, in filter
2024-01-27T21:12:43.277008170Z     record.msg = self.mask_sensitive_data(record.msg)
2024-01-27T21:12:43.277020769Z                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-01-27T21:12:43.277030495Z   File "/usr/local/lib/python3.11/site-packages/mytoyota/utils/logging/log_filters.py", line 23, in mask_sensitive_data
2024-01-27T21:12:43.277039476Z     msg = compiled_pattern.sub("****", msg)
2024-01-27T21:12:43.277047483Z           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-01-27T21:12:43.277055417Z TypeError: expected string or bytes-like object, got 'list'
2024-01-27T21:12:43.277063292Z 2024-01-27 22:12:43 DEBUG Finished fetching toyota data in 1.984 seconds (success: False)

Copy link

codecov bot commented Jan 27, 2024

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (1a17a62) 80.11% compared to head (812633c) 80.11%.

Files Patch % Lines
mytoyota/utils/logging/log_filters.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master     #319   +/-   ##
=======================================
  Coverage   80.11%   80.11%           
=======================================
  Files          32       32           
  Lines        1514     1514           
=======================================
  Hits         1213     1213           
  Misses        301      301           
Flag Coverage Δ
unittests 80.11% <0.00%> (ø)

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.

@CM000n CM000n self-assigned this Jan 27, 2024
@CM000n
Copy link
Collaborator Author

CM000n commented Feb 5, 2024

Hey @GitOldGrumpy can you please take a look and approve if it's ok with you. This solves a problem when setting up the Home Assistant integration when it has updated to MyToyota 1.3.0 in the background.

@CM000n CM000n merged commit a304107 into master Feb 5, 2024
21 checks passed
@CM000n CM000n deleted the CM000n-patch-1 branch February 5, 2024 10:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants