6.0: unified exception hierarchy — no more silent None
Why
Too many failure paths in EdgarTools return None silently — a missing statement, a failed parse, an empty response — leaving users to discover problems three steps downstream as an AttributeError on None. Errors should tell you what went wrong and what to do next.
Scope
- A coherent
edgar.exceptionshierarchy (parse errors, data-availability errors, network/transport errors, usage errors). - Inventory the silent-
Nonepaths and convert them: raise a typed, actionable error, or documentOptionalexplicitly as the contract where absence is genuinely meaningful. Conversions are breaking, so they land in the 6.0 window. - Re-export the transport exception types we raise through our own namespace, so the HTTP-client migration (#842) doesn't break user
exceptclauses — catchingedgar.exceptions.*becomes the stable pattern. - Error messages follow a "useful error" standard: state the input, the failure, and the next step (e.g., which alternative API or data source to try).
Acceptance
- Hierarchy documented with a catching-guide (what to catch for what).
- The silent-
Noneinventory is published and each path is either converted or explicitly contracted asOptional. - A regression-style check: bad/missing input produces a useful error, not
None(this is already our Definition of Done for new features; 6.0 retrofits it).
Downstream consumer data point on the silent-None inventory, since two specific Optional-returning paths sit right at the "genuinely meaningful absence" boundary this issue calls out:
Filing.xbrl()returningNonefor a filing with no XBRL, andCompany.get_facts()returningNonefor a company with no facts,
are both cases we currently treat as meaningful, expected Optional outcomes (a form-type check upstream, or a genuinely fact-less filer) rather than errors — our retry/classification logic distinguishes "filing has no XBRL" (permanent, correctly None today) from "the fetch failed" (transient, should retry). If either flips to always-raise in 6.0, we'd need to add exception handling that reconstructs the exact same distinction from an exception message/type instead of a None check, which seems like it'd be true for other downstream consumers doing this kind of routing too. If there's room in the inventory work to keep these two specifically Optional-by-contract (vs. converting to raise), that would match the issue's own stated criterion for what should stay Optional.
Separately, a concrete case for point 3 (transport re-exports covering the HTTP-client migration): we have our own TransientFilingFetchError built around detecting a symptom of a degraded/rate-limited SEC index response — filing.exhibits returning a container with a None primary document, rather than a typed exception. If the transport re-exports end up covering that specific truncated-index/rate-limited case with a typed signal, we'd be able to delete that structural heuristic entirely in favor of a direct except edgar.exceptions.* catch — happy to be a beta tester / provide the corpus that surfaced the behavior if that's useful for the inventory.
Status update — edgar.exceptions shipped in 5.48.0.
The hierarchy is on PyPI now (edgar/exceptions.py first appears in the 5.48.0 wheel), landed across PRs #1034–#1037 along with a guide at docs/guides/error-handling.md.
The rollout is deliberately two-phase so nothing breaks under you in 5.x:
- Today (5.x): the new exception types exist and the documented error paths raise them, but the old lenient behaviour is still reachable.
EDGARTOOLS_STRICT_ERRORS=1opts you into the 6.0 behaviour early — worth doing now if you'd rather find the affected call sites on your own schedule than at upgrade time. - At 6.0: strict becomes the only path. The
strict_errors_enabled()branches, the 7 deprecated exception aliases,edgar/_compat.py, andResultall get deleted.
Verification: 4,950 fast tests pass both with and without the strict flag, plus tests/issues/regression/test_exceptions_none_flips.py (36 cases pinning specific "returned None, now raises" flips) and test_exceptions_network_boundary.py.
Two things worth knowing if you're following along:
- Deprecation warnings dedup on exact text, so the warning summary attached to an error must not embed an accession number or any other per-instance value — one that varies reintroduces the flood. There's no guard for this yet; it's the known gap.
- The
test-strict-errorsCI job carriesif: github.event_name != 'pull_request', so it never runs pre-merge. Run it locally before merging anything that touches an error path.
Split out and explicitly not required for 6.0: the broader swallowed-exception sweep over the 154 S110/S112 sites.
Thanks for this, and apologies for the slow reply — this deserved an answer three weeks ago rather than a status update posted over it.
Good news on the two paths you named: both already behave the way you're asking for, and the principle behind it is pinned by a test rather than left to judgement.
Filing.xbrl() already draws exactly the distinction your retry logic depends on. It catches the no-XBRL case and returns None, and it re-raises transport failures:
try:
return XBRL.from_filing(self)
except XBRLFilingWithNoXbrlData:
return None
except (*UNREACHABLE_ERRORS, TransportError):
...
raise
So "this filing has no XBRL" is None and permanent; "the fetch failed" raises and is retryable. That's the split you described, and it survives the 5.48.0 exceptions work.
Company.get_facts() is the same shape one level down. CompanyFactsNotFoundError is raised inside entity_facts.py, but Entity.get_facts() catches it and returns None — the conversion to a meaningful absence happens deliberately at the public boundary.
And the criterion you're invoking is already the project's own. There's a regression test called test_obj_still_returns_none_for_a_form_we_do_not_model whose docstring says it better than I would:
This is the distinction the whole change exists for. A flip that made every None into a raise would pass every "does it raise?" test and destroy the thing being protected.
So "no silent None" was never "no None" — it targets None returned instead of an explanation, not None returned as one. Two further things that should reduce your exposure: the flips warn as FutureWarning, which is visible by default rather than hidden like DeprecationWarning, so a future change to either path would show up in your logs before it broke you; and you can run with EDGARTOOLS_STRICT_ERRORS=1 today to get 6.0's behaviour early and see whether anything in your pipeline flips that you didn't expect.
One honest caveat rather than a clean promise: XBRLFilingWithNoXbrlData is on the 6.0 list to be either properly wired or deleted, so the mechanism above may not survive verbatim. The contract — no XBRL means None, transport failure means an exception — is what I'd be committing to keep, and I'd rather say that precisely than imply the code won't move.
On your second point, the transient-fetch signal: that's a real gap, and the most actionable thing in your comment. There is a TooManyRequestsError under TransportError, but your case isn't a clean 429 — you're detecting a degraded or truncated index response structurally, via filing.exhibits coming back with a None primary document. Nothing types that today, which is why you had to build TransientFilingFetchError around a symptom, and a structural heuristic like that is exactly what breaks silently when our parsing changes underneath it.
Yes to the corpus — please. That's the blocker on typing this properly: a truncated index response is easy to describe and hard to reproduce deliberately, and without real captures any exception we add would be guesswork about which shapes to catch. If you can share the filings/responses that surfaced it, I'd like to turn them into cassettes and give that case a typed signal, so except edgar.exceptions.* replaces the heuristic. Open a new issue with them and link it here, or attach them to this thread — whichever is easier.
This shipped in 6.0.0 (2026-11-09). edgar.exceptions holds the hierarchy, transport errors are re-exported there so except clauses survived the httpx2 change, and docs/upgrade/6.0.md covers what to catch. Closing. Please report any remaining silent None as its own issue.