fix(utils): coerce Tavily usage counters to int

JSON APIs sometimes return numeric fields as strings; subtracting them raised TypeError and /status dropped the usage block.
This commit is contained in:
santhreal
2026-07-18 17:23:26 +08:00
committed by Xubin Ren
parent 85097aa143
commit fe0e65928d
2 changed files with 33 additions and 5 deletions
+18
View File
@@ -126,6 +126,24 @@ class TestParseTavilyUsage:
assert info.extract_used is None
assert info.crawl_used is None
def test_string_numeric_fields(self):
data = {
"account": {
"plan_usage": "10",
"plan_limit": "100",
"search_usage": "7",
"extract_usage": "2",
"crawl_usage": "1",
},
}
info = _parse_tavily_usage(data)
assert info.used == 10
assert info.limit == 100
assert info.remaining == 90
assert info.search_used == 7
assert info.extract_used == 2
assert info.crawl_used == 1
# ---------------------------------------------------------------------------
# fetch_search_usage routing tests