Skip to content
New issue

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

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

Already on GitHub? # to your account

Handle empty string cases for source parameters #27

Merged
merged 1 commit into from
Jan 3, 2025
Merged

Conversation

frenck
Copy link
Owner

@frenck frenck commented Jan 3, 2025

Proposed Changes

The source parameters can be empty strings, as shown in this report/comment:

home-assistant/core#134022 (comment)

Error setting up entry Peblar for peblar
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 640, in __async_setup_with_context
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/peblar/__init__.py", line 51, in async_setup_entry
    api = await peblar.rest_api(enable=True, access_mode=AccessMode.READ_WRITE)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/peblar/peblar.py", line 124, in rest_api
    user = await self.user_configuration()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/peblar/peblar.py", line 235, in user_configuration
    return PeblarUserConfiguration.from_json(result)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^
  File "<string>", line 4, in __mashumaro_from_json__
  File "/usr/local/lib/python3.13/site-packages/peblar/models.py", line 414, in __pre_deserialize__
    d["BopSourceParameters"] = orjson.loads(d.get("BopSourceParameters", "{}"))
                               ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
orjson.JSONDecodeError: Input is a zero-length, empty document: line 1 column 1 (char 0)

The existing code handled the case of missing source parameters, but not empty ones. This PR corrects that.

@frenck frenck added the bugfix Inconsistencies or issues which will cause a problem for users or implementers. label Jan 3, 2025
@frenck frenck merged commit 8e582aa into main Jan 3, 2025
24 checks passed
@frenck frenck deleted the frenck-2025-0005 branch January 3, 2025 08:44
@github-actions github-actions bot locked and limited conversation to collaborators Jan 4, 2025
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
bugfix Inconsistencies or issues which will cause a problem for users or implementers.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant