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

Receiving a feed with no data points raises 404 RequestError #119

Open
brentru opened this issue Jul 10, 2020 · 4 comments
Open

Receiving a feed with no data points raises 404 RequestError #119

brentru opened this issue Jul 10, 2020 · 4 comments
Assignees
Labels

Comments

@brentru
Copy link
Member

brentru commented Jul 10, 2020

Calling client.receive on a newly created feed with no data points raises a 404 if no data exists on the feed.

Update the library to not error on that call with a 404, and instead return a None value or a Data type which sets the value as None:

Data(created_epoch=None, created_at='2020-07-10T13:52:52Z', updated_at='2020-07-10T13:52:52Z', value='None', completed_at=None, feed_id=1157950, expiration='1599573172.0', position=None, id='0EG0X017NKRDS5527E3YXN0VP4', lat=None, lon=None, ele=None)

Example code

# Create an instance of the REST client.
aio = Client(ADAFRUIT_IO_USERNAME, ADAFRUIT_IO_KEY)
try: # i we have a 'digital' feed
    digital = aio.feeds('digital')
except RequestError: # create a digital feed
    feed = Feed(name="digital")
    digital = aio.create_feed(feed)
while True:
    print(digital)
    data = aio.receive(digital.key)
    time.sleep(0.5)

Output

Traceback (most recent call last):
File "/home/pi/Documents/digital_out.py", line 45, in <module>
data = aio.receive(digital.key)
File "/home/pi/.local/lib/python3.7/site-packages/Adafruit_IO/client.py", line 216, in receive
return Data.from_dict(self._get(path))
File "/home/pi/.local/lib/python3.7/site-packages/Adafruit_IO/client.py", line 118, in _get
self._handle_error(response)
File "/home/pi/.local/lib/python3.7/site-packages/Adafruit_IO/client.py", line 108, in _handle_error
raise RequestError(response)
Adafruit_IO.errors.RequestError: Adafruit IO request failed: 404 Not Found - not found - API documentation can be found at https://io.adafruit.com/api/docs
@brentru brentru added the bug label Jul 10, 2020
@blacklight
Copy link

Not sure if this library is still maintained, but this is a core breaking bug that has been open for at least a year. Is there any plan to tackle it or will someone try and fork the library?

@RobisLV
Copy link

RobisLV commented Aug 2, 2021

Can confirm. I am experiencing the same bug.

>>> aio.receive("myfeed") Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/lib/python3.7/dist-packages/adafruit_io-2.5.0-py3.7.egg/Adafruit_IO/client.py", line 216, in receive File "/usr/local/lib/python3.7/dist-packages/adafruit_io-2.5.0-py3.7.egg/Adafruit_IO/client.py", line 118, in _get File "/usr/local/lib/python3.7/dist-packages/adafruit_io-2.5.0-py3.7.egg/Adafruit_IO/client.py", line 108, in _handle_error Adafruit_IO.errors.RequestError: Adafruit IO request failed: 404 Not Found - not found - API documentation can be found at https://io.adafruit.com/api/docs

@brunofcat
Copy link

the same issue.

@tyeth tyeth self-assigned this Dec 6, 2024
@tyeth
Copy link
Contributor

tyeth commented Dec 6, 2024

Just spotted this issue, I should have probably fixed it instead of fixing the example in #160 🤦
Added to my list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants