TypeError: 'str' object does not support item assignment
DionAkkerman opened this issue · comments
The vast majority of the time this situation does not arise but when querying a certain IP I get the following traceback:
Traceback (most recent call last):
File "", line 1, in
ip_output = api_client.ip(lama)
File ".../greynoise/api/init.py", line 233, in ip
response["ip"] = ip_addressTypeError: 'str' object does not support item assignment
This seems to occur when the query returns an empty string. if I monkeypatch the ip method in
greynoise/api/init.py using:
try:
if "ip" not in response:
response["ip"] = ip_address
except:
response = {"ip": ip_address, "out": response}
instead of the original:
if "ip" not in response:
response["ip"] = ip_address
The issue does not occur and I can see that 'response' was an empty string.
Thanks so much for catching this. Can you give me an IP that this error is occurring on for us to troubleshoot on the server side? I think we should handle this on both the client and the server side.
Fixed. There was a bug in the API when processing certain rare cases.
Thanks @DionAkkerman for reporting!