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

geo_json_events / simplejson.errors.JSONDecodeError: Expecting value: line 3 column 1 (char 4) #102630

Closed
codyc1515 opened this issue Oct 24, 2023 · 5 comments · Fixed by #107866

Comments

@codyc1515
Copy link
Contributor

The problem

Receiving this error several times now. Unclear cause. Perhaps the JSON suddenly became invalid, though I cannot imagine why (server error?).

Logger: homeassistant
Source: components/geo_json_events/manager.py:74
First occurred: 12:44:10 (2 occurrences)
Last logged: 13:19:12

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/geo_json_events/manager.py", line 63, in update
    await self.async_update()
  File "/usr/src/homeassistant/homeassistant/components/geo_json_events/manager.py", line 74, in async_update
    await self._feed_manager.update()
  File "/usr/local/lib/python3.11/site-packages/aio_geojson_client/feed_manager.py", line 74, in update
    status, feed_entries = await self._feed.update()
                           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aio_geojson_client/feed.py", line 102, in update
    return await self._update_internal(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aio_geojson_client/feed.py", line 67, in _update_internal
    status, data = await self._fetch()
                   ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aio_geojson_client/feed.py", line 129, in _fetch
    feature_collection = geojson.loads(text)
                         ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/geojson/codec.py", line 51, in loads
    return json.loads(s,
           ^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/simplejson/__init__.py", line 533, in loads
    return cls(encoding=encoding, **kw).decode(s)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/simplejson/decoder.py", line 386, in decode
    obj, end = self.raw_decode(s)
               ^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/simplejson/decoder.py", line 416, in raw_decode
    return self.scan_once(s, idx=_w(s, idx).end())
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
simplejson.errors.JSONDecodeError: Expecting value: line 3 column 1 (char 4)

What version of Home Assistant Core has the issue?

2023.10.5

What was the last working version of Home Assistant Core?

2023.10.3

What type of installation are you running?

Home Assistant OS

Integration causing the issue

geo_json_events

Link to integration documentation on our website

https://www.home-assistant.io/integrations/geo_json_events/

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

@home-assistant
Copy link

Hey there @exxamalte, mind taking a look at this issue as it has been labeled with an integration (geo_json_events) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of geo_json_events can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Renames the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign geo_json_events Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


geo_json_events documentation
geo_json_events source
(message by IssueLinks)

@exxamalte
Copy link
Contributor

Could you please confirm: This issue occurs with a GeoJSON feed that works most of the time, but occasionally shows this issue?
Is this a public feed, and if so, could you please share the URL you have configured? That might help with debugging this issue.

@codyc1515
Copy link
Contributor Author

Likely there was a server error at that point in time but the integration does not handle this well.

@codyc1515
Copy link
Contributor Author

Still current.

@exxamalte
Copy link
Contributor

Further analysis shows that this particular issue happens because your HA environment (like mine) happens to have the simplejson library installed to parse incoming JSON data. The integration and its library do not actually define this dependency, so it comes from somewhere else. The integration is already catching JSON decode errors if using the built-in Python json decoder, but it does do that when using the the simplejson library.
I am going to take a look if I can make error handling a little bit more generic, while avoiding to actually create a dependency on the simplejson library.

@github-actions github-actions bot locked and limited conversation to collaborators Feb 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants