ExpatError: no element found: line 1, column 0
aaronsky opened this issue · comments
I installed xiblint 0.9.1 and am trying to run it against a codebase of a few hundred xibs and storyboards. I'm getting this error that's preventing it from proceeding.
Error
Traceback (most recent call last):
File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/xml/etree/ElementTree.py", line 1637, in close
self.parser.Parse("", 1) # end of data
xml.parsers.expat.ExpatError: no element found: line 1, column 0
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/bin/xiblint", line 11, in <module>
sys.exit(main())
File "/usr/local/lib/python3.7/site-packages/xiblint/__main__.py", line 67, in main
errors += process_file(file_path, config)
File "/usr/local/lib/python3.7/site-packages/xiblint/__main__.py", line 79, in process_file
context = XibContext(file_path)
File "/usr/local/lib/python3.7/site-packages/xiblint/xibcontext.py", line 10, in __init__
self.tree = parse_xml(path)
File "/usr/local/lib/python3.7/site-packages/xiblint/xmlutils.py", line 32, in parse_xml
tree = ElementTree.parse(file_path, parser=parser)
File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/xml/etree/ElementTree.py", line 1197, in parse
tree.parse(source, parser)
File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/xml/etree/ElementTree.py", line 605, in parse
self._root = parser.close()
File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/xml/etree/ElementTree.py", line 1639, in close
self._raiseerror(v)
File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/xml/etree/ElementTree.py", line 1531, in _raiseerror
raise err
xml.etree.ElementTree.ParseError: no element found: line 1, column 0
.xiblint.json:
{
"rules": [
"accessibility_labels_for_image_buttons",
"accessibility_labels_for_images",
"accessibility_labels_for_text_with_placeholder",
"autolayout_frames",
"automation_identifiers",
"automation_identifiers_for_outlet_labels",
"no_simulated_metrics",
"no_trait_variations",
"simulated_metrics_retina4_0"
],
"include_paths": [
"Apps",
"Customer Apps",
"Features",
"Infrastructure",
"Shared Frameworks"
]
}
Running on macOS High Sierra with Xcode 10 beta 5 as my command line tools. I am running Python 3.7 installed via Homebrew. Please let me know if you need any additional information
We probably need to add handling for this error and surface it along with the file that experienced the error.
Does that mean you have a sense of what could have caused this error, or is it impossible to know without the nib that tripped it?
Upon further inspection and some debugging of the program, it appears that the file that was causing xiblint to fail was an empty file. This is definitely a case of user error, so I'm going to close this.
Still, we should make it easier to understand which file we stumbled on. Another likely cause for XML parsing failure would be conflict markers. We want to fail on those, but not mysteriously.