Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Handle string values in enum facts #630

Open
aaroncameron-wk opened this issue Feb 13, 2024 · 3 comments
Open

[BUG] Handle string values in enum facts #630

aaroncameron-wk opened this issue Feb 13, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@aaroncameron-wk
Copy link
Contributor

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

@aaroncameron-wk aaroncameron-wk added the bug Something isn't working label Feb 13, 2024
@brettkail-wk
Copy link
Contributor

We apparently also need to handle cases where xValue is str or list[str].

Alternatively, should Arelle be ensuring that all isEnumeration concept values are list[QName]? I guess this is the current condition, so is there some non-xs:token non-xs:QName type in that list that is causing str (probably, then converted to a tuple) to be returned? Do you have more information on which type/concept it is?

@paulwarren-wk
Copy link
Contributor

Alternatively, should Arelle be ensuring that all isEnumeration concept values are list[QName]? I guess this is the current condition, so is there some non-xs:token non-xs:QName type in that list that is causing str (probably, then converted to a tuple) to be returned? Do you have more information on which type/concept it is?

There was a 2016 PWD of Extensible Enumerations 1.1 that was based on string, not token (XbrlConst.qnEnumerationsItemType2016). That is supposed to hold a list of QNames so should be treated as baseXsdType = "enumerationQNames". I don't understand what the check for token is doing. If you were to remove it, I think it would handle the 2016 type correctly, although I'd be surprised if anyone is using that spec, and I don't think it's worth expending any effort on supporting it in Arelle.

@paulwarren-wk
Copy link
Contributor

@aaroncameron-wk do you have a document that demonstrates this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants