Inline XBRL parsing resolves contexts and units only within one HTML file, so EX-13 facts get context and unit None
Issue Type
- [ ] Data Quality Issue (incorrect financial values, missing data)
- [x] XBRL Parsing Issue (statement rendering, concept mapping)
- [ ] Filing Access Issue (download failures, attachment problems)
- [ ] Performance Issue (slow operations, memory problems)
- [ ] Compatibility Issue (platform/dependency conflicts)
- [ ] Documentation Issue (unclear instructions, missing examples)
Environment
EdgarTools Version: 5.62.0 (main at commit 2323d732 reports 5.62.0; the v5.62.0 tag at commit 5068cc54 gives the same output) Python Version: 3.14.4 Operating System: Windows 11
Bug Description
What you expected to happen:
A fact's context and unit are the xbrli:context and xbrli:unit with that id anywhere in the Inline XBRL Document Set. Under Inline XBRL 1.1 (§3.1 Document Set, §4.1.2, §8.1.3, §10.1, §14.1.2) only the set as a whole needs an ix:header, and an ix:continuation may sit in another document of the set. Facts in an exhibit such as an EX-13 that holds the financial statements should therefore carry their period, entity, dimensions and unit.
What actually happened:
XBRLExtractor._initialize_context (edgar/documents/strategies/xbrl_extraction.py, lines 188-213) collects contexts, units and continuations only from element.getroottree() of the one HTML string being parsed. HTMLParser._extract_xbrl_pre_process (edgar/documents/parser.py, from line 305) builds a fresh XBRLExtractor for each document, and no API accepts the other documents of the set. A continuation that is not found is logged only at debug level (xbrl_extraction.py, line 480).
On IBM's FY2024 10-K fixture, ix.htm (the EX-13, ibm-20241231_d2) has no ix:header of its own; its contexts and units are in the header of ibm-20241231.htm. Parsing ix.htm returns 3,983 facts, all with context None, and 3,734 facts that carry a unitRef with unit None. For example us-gaap:Revenues with contextRef c-62 and value 29813000000 has context None and unit None, although c-62 is defined in ibm-20241231.htm. The same call on ibm-20241231.htm resolves the context of all 241 of its facts.
Error message (if any):
N/A: no error is raised. Context and unit are returned as None.
Reproduction
Company/Ticker: IBM Time Period: FY2024 (period ending 2024-12-31) Relevant Forms: 10-K (EX-13 exhibit)
Minimal code to reproduce:
# Run from the root of an edgartools checkout (uses the IBM fixtures in tests/).
from edgar import set_identity
from edgar.documents import parse_html
set_identity("Your Name [email protected]")
folder = "tests/fixtures/xbrl/ibm/10k_2024"
for name in ("ix.htm", "ibm-20241231.htm"): # ix.htm is IBM's EX-13 (ibm-20241231_d2.htm)
facts = parse_html(open(f"{folder}/{name}", encoding="utf-8").read()).xbrl_facts
print(name, "facts:", len(facts),
"| context None:", sum(f.context is None for f in facts),
"| unitRef set but unit None:", sum(bool(f.unit_ref) and f.unit is None for f in facts))
rev = next((f for f in facts if f.concept == "us-gaap:Revenues"), None)
if rev:
print(" us-gaap:Revenues contextRef", rev.context_ref, rev.value,
"-> context", rev.context, "unit", rev.unit)
Additional Context
Output observed on main at commit 2323d732 (identical on v5.62.0 at commit 5068cc54):
ix.htm facts: 3983 | context None: 3983 | unitRef set but unit None: 3734
us-gaap:Revenues contextRef c-62 29813000000 -> context None unit None
ibm-20241231.htm facts: 241 | context None: 0 | unitRef set but unit None: 0
When this happens, every fact of the exhibit loses its period, entity, dimensions and unit, so 2024 revenue cannot be told from 2023 revenue or from a segment's. Multi-document sets (an EX-13 holding the statements) are uncommon, and the XBRL instance path, which reads the SEC's extracted instance, is unaffected.
This issue will be handled using EdgarTools' systematic issue resolution workflow. A reproduction test will be created to verify the fix.
@dgunning, here is our current thinking on the root cause, proposed behavior, and coordination with other issues.
Root Cause:
Each inline extractor scans one HTML tree, so an exhibit cannot resolve contexts or units held in another supplied filing document. The IBM pair demonstrates this resource gap; missing namespace declarations in its committed fixture are a separate fixture defect, not a defect in IBM's filed documents.
Proposed Behavior:
Provide an explicit offline parse_inline_xbrl_set API with one source-aware index for contexts, units and continuations, preserving each document's own fact list. Resolve resources across the supplied set and QNames in their own source, with strict errors by default and explicit partial results in best-effort mode. Retain full dimensional and compound-unit detail, aligning typed-child nil as None, empty text as '' and an absent axis as absent, with the compatibility change disclosed. With its own filed declarations restored, IBM's f-204 remains 29813000000 for the technology-service member slice, distinct from consolidated revenue; damaged-input controls retain explicit namespace failures.
Coordination:
Keep #1753 as its own PR after agreeing shared source fields with #1756/#1757, allowing smaller nil and identity work to precede integration. Align typed records with #1761/#1751, and restore the IBM fixture declarations before or within #1743. Preserve landed #1755 and PR #1816's lookup approach; keep #1748/#1770's content repairs and PR #1803's fractions separate.
Below, please find the full design document. Please let me know your thoughts.
Brian
Attachment: design-public.md, Resolve inline resources across an explicit document set — #1753.
AI assistance: Codex; GPT-6.1 Sol (High) reproduced the current-main IBM case, checked its dimensioned source context and finalized the public text. GPT-6 Astra (Max) developed the architecture using current code and the primary Inline XBRL specification; a separate GPT-6 Astra (Max) completed independent financial/source-contract review and reread the namespace and compound-unit corrections. Claude Opus 5.5 (High) performed adversarial review and independent resolver review, including the filed IBM namespace evidence; GPT-6.1 Sol (High) revised source characterization, regression expectations and companion contracts. A separate GPT-6.1 Sol (High) completed focused independent financial/source review of the revised proposal.
Thanks Brian. A separate parse_inline_xbrl_set makes sense, and since it's new API it can land in any release. I'll take it in 6.x after #1756 and #1757. When it goes in, the change to how nil and empty typed values come back will get its own changelog line.