HKUDS/Vibe-Trading · error · RuntimeError
EDGAR filing feed did not parse: {exc}
Error message
EDGAR filing feed did not parse: {exc} What it means
The EDGAR atom filing feed (browse-edgar filer feed, output=atom) was fetched but its body is not parseable XML — defusedxml raised while parsing. The raw body is likely an HTML error page (403/404 rate-limit page) rather than the atom feed.
Source
Thrown at agent/src/tools/etf_holdings_tool.py:539
Raises:
requests.RequestException: Network failure or non-2xx status.
"""
body = _sec_get_text(
_SEC_BROWSE_URL,
params={
"action": "getcompany",
"CIK": series_id,
"type": "NPORT-P",
"dateb": "",
"owner": "include",
"count": str(_SEC_FILING_COUNT),
"output": "atom",
},
)
try:
root = DefusedET.fromstring(body.encode("utf-8", "replace"))
except Exception as exc: # noqa: BLE001 - a malformed feed is a data error
raise RuntimeError(f"EDGAR filing feed did not parse: {exc}") from exc
filings: list[dict[str, Any]] = []
for element in root.iter():
if _local_name(element.tag) != "content":
continue
fields = {_local_name(c.tag): (c.text or "").strip() for c in element}
accession = fields.get("accession-number")
if not accession:
continue
filings.append(
{
"form": fields.get("filing-type") or None,
"accession": accession,
"filing_date": fields.get("filing-date") or None,
}
)
return filings
View on GitHub (pinned to 80ffdda44c)
Solutions
- Add throttling (>=1 req/sec) and retry with backoff around the feed fetch
- Send a declared User-Agent like 'SampleCo admin@example.com' per SEC policy
- Inspect the raw body just before the raise to confirm which error page SEC returned
- Cache feed results per CIK to avoid repeated hits
Defensive patterns
Strategy: retry
Validate before calling
import xml.etree.ElementTree as ET
def feed_looks_like_atom(body: str) -> bool:
try:
ET.fromstring(body.encode("utf-8", "replace"))
return True
except ET.ParseError:
return False Try / catch
for attempt in range(4):
try:
filings = _us_nport_filings(cik)
break
except RuntimeError as exc:
if "feed did not parse" in str(exc) and attempt < 3:
time.sleep(1.5 ** attempt)
continue
raise Prevention
- Rate-limit EDGAR calls and send a compliant User-Agent
- Cache atom feed responses per CIK+period to avoid repeat fetches
- Treat HTML bodies (starts with '<!DOCTYPE html') as rate-limit signals and back off before parsing
When it happens
Trigger: Calling _holdings_us for a CIK whose N-PORT feed request returns SEC's HTML 'too many requests' or error page; proxy/mitm rewriting responses; truncated response bodies.
Common situations: Hitting SEC's 10-req/sec fair-access rate limit in loops; CI runners sharing an IP; sec.gov blocking default client user-agents; transient 5xx bodies.
Related errors
- N-PORT document did not parse: {exc}
- SEC investment-company series/class index unavailable ({'; '
- EDGAR full-text search returned no hits block: {message or p
- invalid alpha_id
- alpha_id not found
AI-assisted analysis of HKUDS/Vibe-Trading@80ffdda44c (2026-08-28).
Data as JSON: /api/errors/4b40e86be9a64dab.
Report an issue: GitHub.