edgartools icon indicating copy to clipboard operation
edgartools copied to clipboard

Inline-parsed `Document.xbrl_facts` has no nil state: a nil fact written with the `xs:` prefix reads as an empty string

Open synfonia-llc opened this issue 1 month ago • 1 comments

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: main@2323d732 (reports 5.62.0); same output on v5.62.0 (5068cc54) Python Version: 3.14 Operating System: Windows 11

Bug Description

What you expected to happen: A fact filed with xsi:nil="true" is a reported nil fact (Inline XBRL 1.1 §10.1.1 and §11.2.3; XBRL 2.1 §5.2.5.2). The documents path should carry it on XBRLFact as nil, distinct from a fact whose content is empty, and should recognise the nil attribute by its namespace (http://www.w3.org/2001/XMLSchema-instance) whatever prefix the filer binds to it.

What actually happened: AAR CORP's 10-Q 0001104659-26-111786 binds the XML Schema instance namespace to two prefixes, xsi and xs, and files both us-gaap:PreferredStockValue facts (contexts As_Of_8_31_2026_... and As_Of_5_31_2026_...) as xs:nil="true". Document.xbrl_facts returns each with value == '', numeric_value None and metadata == {'hidden': True}. XBRLFact (edgar/documents/types.py) has no nil field, and the documents-path extractor (edgar/documents/strategies/xbrl_extraction.py) does not read the nil attribute, so a nil fact cannot be told apart from an empty one.

A related prefix test, read in the source and not run here: the 424B fee reader skips nil facts with elem.get('xsi:nil') == 'true' (edgar/offerings/prospectus/_424b_xbrl.py, line 110), which matches only the literal prefix xsi.

Error message (if any):

Not applicable

Reproduction

Company/Ticker: AAR CORP Time Period: quarter ended 2026-08-31 (balance sheet dates 2026-08-31 and 2026-05-31) Relevant Forms: 10-Q

Minimal code to reproduce:

from edgar import set_identity
set_identity("Your Name [email protected]")
import re
import dataclasses
from edgar import find
from edgar.documents.types import XBRLFact
filing = find("0001104659-26-111786")
print(filing.form, filing.company, filing.accession_no)
html = filing.html()
# The nil fact as filed, and the prefix bound to the XML Schema instance namespace
print("xsi prefix bound:", re.findall(r'xmlns:(\w+)="http://www.w3.org/2001/XMLSchema-instance"', html))
for tag in re.findall(r'<ix:nonFraction[^>]*PreferredStockValue[^>]*>', html):
    print("filed:", tag)
doc = filing.parse()
facts = [f for f in doc.xbrl_facts if f.concept == "us-gaap:PreferredStockValue"]
for f in facts:
    print("parsed:", repr(f.value), f.numeric_value, f.context_ref, f.metadata)
print("XBRLFact has a nil field:", any("nil" in fl.name for fl in dataclasses.fields(XBRLFact)))

Output on main@2323d732:

10-Q AAR CORP 0001104659-26-111786
xsi prefix bound: ['xsi', 'xs']
filed: <ix:nonFraction unitRef="Unit_Standard_USD_jD9ithXMDkWtmXnfcjYp2g" xs:nil="true" contextRef="As_Of_8_31_2026_RKa0U921gE29Ycy6p0__VQ" name="us-gaap:PreferredStockValue" id="Hidden_V9bqEXx7gEeLpiX1CZEhew">
filed: <ix:nonFraction unitRef="Unit_Standard_USD_jD9ithXMDkWtmXnfcjYp2g" xs:nil="true" contextRef="As_Of_5_31_2026_VLLYpglH9UmKSlBYcpXZIg" name="us-gaap:PreferredStockValue" id="Hidden_ESy6gmP2xU2vF0fZIjJ-tQ">
parsed: '' None As_Of_8_31_2026_RKa0U921gE29Ycy6p0__VQ {'hidden': True}
parsed: '' None As_Of_5_31_2026_VLLYpglH9UmKSlBYcpXZIg {'hidden': True}
XBRLFact has a nil field: False

Additional Context

The parsed nil value is not read as 0: numeric_value is None. The loss is the nil state itself; consumers of Document.xbrl_facts cannot tell "reported as nil" from "empty or unparsed".

Related: #1254 (the same nil state on the XBRL path's Fact/FactQuery; this report is the documents path, a separate public API, and the prefix test).


This issue will be handled using EdgarTools' systematic issue resolution workflow. A reproduction test will be created to verify the fix.

synfonia-llc avatar Oct 22 '26 15:10 synfonia-llc

@dgunning, here is our current thinking on the root cause, proposed behavior, and coordination with other issues.

Root Cause:

XBRLFact has no nil field, and inline extraction never reads the namespace-qualified nil attribute. AAR’s xs:nil="true" therefore becomes empty content without its explicit source state; the observed case did not become zero.

Proposed Behavior:

Add and export XBRLFact.is_nil, resolving the attribute by namespace URI rather than a literal prefix. Recognize true nil before transformation, scaling and sign so even a successful fixed-zero cannot turn it into an amount. Preserve source content and metadata, keep its numeric value unavailable, and expose displayed content or ambiguous namespaces through explicit diagnostics. Keep nil distinct from empty non-nil content, an absent fact and ordinary numeric zero.

Coordination:

Keep this nil PR first, followed by the combined source-preservation PR in the supplemental attachment for raw precision, retained input/export/failures and exact scale/sign. Full registry #1743, duration #1754 and remaining accuracy/ranking #1765 stay separate; share source-marker meaning with #1254 while retaining its different instance-conversion behavior. Share the namespace helper with #1753/#1756, without waiting for their APIs, and preserve fixed #1755.

Below, please find the full design document. Please let me know your thoughts.

Brian

Attachment: design-public.md, Preserve explicit nil on inline facts — #1757.

Supplemental attachment: precision-design-public.md, Preserve non-fraction XBRL source values and declared accuracy.

AI assistance: Codex; gpt-6.1-sol (High) performed current-main reproduction, source verification and final writing; gpt-6-astra (Max) prepared the architecture and reviewed the parser and primary specifications; a separate gpt-6-astra (Max) completed independent financial/source-contract review and reread the nil-first correction.

synfonia-llc avatar Oct 27 '26 11:10 synfonia-llc