Repository: tellor-io/telliot-feeds (language: python)

Issue:
"eth_abi.exceptions.EncodingTypeError"
This error was encountered running with the start command: `telliot report -a goerli6 -s 10000 -p YOLO -wp 300 -rf`

versions: 
telliot-core.git@c4898d70ce7b035e59d118e170e9d0a977993b7b
telliot-feeds.git@30597c491f6c6b25e48cbc605ad842fa465bdc32

Full traceback attached: 
[eth_abi.exception.txt](https://github.com/tellor-io/telliot-feeds/files/10548853/eth_abi.exception.txt)



Discussion / hints:

Fix patch:
diff --git a/src/telliot_feeds/reporters/tellor_360.py b/src/telliot_feeds/reporters/tellor_360.py
index 8ae63b57..7f06d33d 100644
--- a/src/telliot_feeds/reporters/tellor_360.py
+++ b/src/telliot_feeds/reporters/tellor_360.py
@@ -6,6 +6,7 @@
 from typing import Optional
 from typing import Tuple
 
+from eth_abi.exceptions import EncodingTypeError
 from eth_utils import to_checksum_address
 from telliot_core.utils.response import error_status
 from telliot_core.utils.response import ResponseStatus
@@ -198,7 +199,12 @@ async def rewards(self) -> int:
         total_rewards: int = 0
 
         if self.datafeed is not None:
-            fetch_autopay_tip = await fetch_feed_tip(self.autopay, self.datafeed.query.query_id)
+            try:
+                qid = self.datafeed.query.query_id
+                fetch_autopay_tip = await fetch_feed_tip(self.autopay, qid)
+            except EncodingTypeError:
+                logger.warning(f"Unable to generate data/id for query: {self.datafeed.query}")
+
             if fetch_autopay_tip is not None:
                 total_rewards += fetch_autopay_tip
 
diff --git a/src/telliot_feeds/reporters/tellor_flex.py b/src/telliot_feeds/reporters/tellor_flex.py
index a24b333a..0faf4bf9 100644
--- a/src/telliot_feeds/reporters/tellor_flex.py
+++ b/src/telliot_feeds/reporters/tellor_flex.py
@@ -8,6 +8,7 @@
 from typing import Union
 
 from chained_accounts import ChainedAccount
+from eth_abi.exceptions import EncodingTypeError
 from eth_utils import to_checksum_address
 from telliot_core.contract.contract import Contract
 from telliot_core.gas.legacy_gas import legacy_gas_station
@@ -236,8 +237,13 @@ async def fetch_datafeed(self) -> Optional[DataFeed[Any]]:
         if query tag is selected fetches the rewards, if any, for that query tag"""
         if self.datafeed:
             # add query id to catalog to fetch tip for legacy autopay
-            if self.datafeed.query.query_id not in CATALOG_QUERY_IDS:
-                CATALOG_QUERY_IDS[self.datafeed.query.query_id] = self.datafeed.query.descriptor
+            try:
+                qid = self.datafeed.query.query_id
+            except EncodingTypeError:
+                logger.warning(f"Unable to generate data/id for query: {self.datafeed.query}")
+                return None
+            if qid not in CATALOG_QUERY_IDS:
+                CATALOG_QUERY_IDS[qid] = self.datafeed.query.descriptor
             self.autopaytip = await self.rewards()
             return self.datafeed
 


Test patch:
diff --git a/tests/queries/test_query_support.py b/tests/queries/test_query_support.py
index 67ebcf4f..03a82cc7 100644
--- a/tests/queries/test_query_support.py
+++ b/tests/queries/test_query_support.py
@@ -24,3 +24,14 @@ def test_all_query_types_in_catalog():
     for q in JsonQuery.__subclasses__():
         print("Checking", q.__name__)
         assert q.__name__ in q_types
+
+
+def test_gen_all_query_ids():
+    """Test that all query IDs can be generated."""
+    for q in AbiQuery.__subclasses__():
+        print("Checking", q.__name__)
+        q.query_id
+
+    for q in JsonQuery.__subclasses__():
+        print("Checking", q.__name__)
+        q.query_id
diff --git a/tests/reporters/test_360_reporter.py b/tests/reporters/test_360_reporter.py
index 1c766619..5c0c227c 100644
--- a/tests/reporters/test_360_reporter.py
+++ b/tests/reporters/test_360_reporter.py
@@ -238,3 +238,33 @@ async def mock_get_feed_and_tip(*args, **kwargs):
     reporter.datafeed = None
     await reporter.report(report_count=1)
     assert "Currently in reporter lock. Time left: 11:59" in caplog.text
+
+
+@pytest.mark.asyncio
+async def test_fail_gen_query_id(tellor_360, monkeypatch, caplog, guaranteed_price_source):
+    """Test failure to generate query id when calling rewards() method."""
+    contracts, account = tellor_360
+    feed = eth_usd_median_feed
+    feed.source = guaranteed_price_source
+
+    reporter_kwargs = {
+        "oracle": contracts.oracle,
+        "token": contracts.token,
+        "autopay": contracts.autopay,
+        "endpoint": contracts.oracle.node,
+        "account": account,
+        "chain_id": CHAIN_ID,
+        "transaction_type": 0,
+        "wait_period": 0,
+        "min_native_token_balance": 0,
+        "datafeed": feed,
+    }
+
+    # This will cause the SpotPrice query to throw an eth_abi.exceptions.EncodingTypeError when
+    # trying to generate the query data for the query id.
+    eth_usd_median_feed.query.asset = None
+
+    reporter = Tellor360Reporter(**reporter_kwargs)
+    _ = await reporter.rewards()
+
+    assert "Unable to generate data/id for query" in caplog.text