fix(serialization): render concept labels in XBRL/JSON-LD export#733
Merged
Conversation
…base The XBRL/JSON-LD bundle set BundleElement.label = element.description, which is NULL for most concepts; _concept_label then fell back to element.name and suppressed it when it equalled the QName localpart. So single-word fundamentals whose name is the bare localname (Assets, Cash, Liabilities, Revenues, Goodwill, Land, Depreciation, Depletion, Communication) lost their label entirely and arelle rendered the QName (rs-gaap:Assets) instead of 'Assets'. JSON-LD skos:prefLabel was affected the same way. Source BundleElement.label from element_labels (role=standard, lang=en) in bundle.py, falling back to description only when no standard label exists. Fixes all 9 affected concepts in both the XBRL label linkbase and JSON-LD prefLabel, and broadly improves prefLabel coverage. 3 regression tests.
Add rdfs:label (the standard label) to 5 rs-gaap concepts that had none, so they render a label instead of their QName in the library browser / full-taxonomy XBRL export: IncomeTaxExpenseBenefitContinuingOperations, LiabilitiesAndPartnersCapital, NetInterestIncomeLossAfterProvisionForLoanLosses, SecondaryProcessingRevenue, VehicleTollRevenue. All 5 are tenant-excluded verticals, so this only affects the public library; needs a library reseed to land. Pairs with the serialization fix that sources the standard label.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fundamental concepts (
Assets,Cash,Liabilities,Revenues,Goodwill, …) rendered as their QName (rs-gaap:Assets) instead of their label in the XBRL export (arelle) and the JSON-LDskos:prefLabel. Root cause: the serialization bundle sourced the concept label fromelement.description(NULL for these) rather than the standard label linkbase, and the QName-echo suppression then dropped theelement.namefallback for single-word concepts whose name equals the QName localpart. This sources the standard label instead, and backfills standard labels for 5 concepts that genuinely had none.Changes
Serialization —
operations/serialization/bundle.pyBundleElement.labelis now sourced fromelement_labels(role=standard, lang=en), falling back toelement.descriptiononly when no standard label exists. Adds a scopedElementLabelquery inbuild_report_bundleand astandard_labelparam on_element_to_bundle.Assets,Cash,Communication,Depletion,Depreciation,Goodwill,Land,Liabilities,Revenues) in both the XBRL label linkbase and JSON-LDskos:prefLabel(jsonld.pyemitsprefLabelfromBundleElement.label), and broadly improves prefLabel coverage (previously the near-always-null description).name == localname; a single-word label equal to the localname is emitted in the label linkbase.Taxonomy data —
frameworks/rs-gaap/packages/rs-gaap/v1/taxonomy.jsonldrdfs:label(the standard label) to 5 previously-unlabeled concepts:IncomeTaxExpenseBenefitContinuingOperations,LiabilitiesAndPartnersCapital,NetInterestIncomeLossAfterProvisionForLoanLosses,SecondaryProcessingRevenue,VehicleTollRevenue. All 5 are tenant-excluded verticals, so this affects only the public library / full-taxonomy export (the library-browser view where they showed as QNames); it needs a library reseed to land.Testing
uv run pytest tests/operations/serialization/→ 125 passed (incl. the 3 new).ruff check/ruff format/basedpyrighton changed files → clean.rs-gaap:Assetshaselement_labelsrole=standardtext="Assets" in the seeded library, so the new query sources it.just reset-localto reach the public library.just test-allnot run.Notes / Follow-ups
_concept_label'sname == localnamesuppression is retained as a final fallback for concepts with neither a standard label nor a description (acceptable — truly unlabeled → QName).