Skip to content

[BUG] Handle string values in enum facts #630

@aaroncameron-wk

Description

@aaroncameron-wk

What happened?

It appears that xValue in this context can be a str or list containing a str. This means a str may be passed in self.nsmap.qname(qn) which causes the below exception.

elif f.concept is not None and f.concept.isEnumeration:
qnEnums = f.xValue
if qnEnums is None:
factData["v"] = f.value
factData["err"] = 'INVALID_IX_VALUE'
else:
if not isinstance(qnEnums, list):
qnEnums = (qnEnums,)
factData["v"] = " ".join(self.nsmap.qname(qn) for qn in qnEnums)

'str' object has no attribute 'namespaceURI'
  File "/usr/local/lib/python3.12/site-packages/iXBRLViewerPlugin/iXBRLViewer.py", in createViewer
    self.addFact(report, f)
  File "/usr/local/lib/python3.12/site-packages/iXBRLViewerPlugin/iXBRLViewer.py", in addFact
    factData["v"] = " ".join(self.nsmap.qname(qn) for qn in qnEnums)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/iXBRLViewerPlugin/iXBRLViewer.py", in <genexpr>
    factData["v"] = " ".join(self.nsmap.qname(qn) for qn in qnEnums)
                             ^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/iXBRLViewerPlugin/iXBRLViewer.py", in qname
    return "%s:%s" % (self.getPrefix(qname.namespaceURI, qname.prefix), qname.localName)
                                     ^^^^^^^^^^^^^^^^^^

A similar issue was recently handled in a recent PR. It currently relies on the assumption that xValue is either None (if the value is missing or invalid) or it is a QName or list[QName]. We apparently also need to handle cases where xValue is str or list[str].

Version

1.4.17

With which browsers are you experiencing the bug?

Firefox, Chrome, Safari, Microsoft Edge

Documents

No response

Screenshots

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions