dcermak / rpm-spec-language-server

Language Server for RPM spec files
GNU General Public License v2.0
18 stars 3 forks source link

Server error when editing a spec file #73

Open danyspin97 opened 6 months ago

danyspin97 commented 6 months ago

I have this error while editing python-mysqlclient:

ERROR:_handle_request:Failed to handle request 25 textDocument/documentSymbol DocumentSymbolParams(text_document=TextDocumentIdentifier(uri='file:///home/danyspin97/proj/openSUSE/devel:languages:python/python-mysqlclient/python-mysqlclient.spec'), work_done_token=None, partial_result_token=None)
Traceback (most recent call last):
  File "/home/danyspin97/.local/lib/python3.11/site-packages/pygls/protocol/json_rpc.py", line 266, in _handle_request
    self._execute_request(msg_id, handler, params)
  File "/home/danyspin97/.local/lib/python3.11/site-packages/pygls/protocol/json_rpc.py", line 188, in _execute_request
    self._send_response(msg_id, handler(params))
                                ^^^^^^^^^^^^^^^
  File "/home/danyspin97/.local/lib/python3.11/site-packages/rpm_spec_language_server/server.py", line 247, in spec_symbols
    spec_sections := server.spec_sections_from_cache_or_file(
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/danyspin97/.local/lib/python3.11/site-packages/rpm_spec_language_server/server.py", line 120, in spec_sections_from_cache_or_file
    self.spec_files[uri] = (sect := SpecSections.parse(spec))
                                    ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/danyspin97/.local/lib/python3.11/site-packages/rpm_spec_language_server/document_symbols.py", line 44, in parse
    name = f"{name} {spec.name}-{opt.split()[0]}"
                     ^^^^^^^^^
  File "/home/danyspin97/.local/lib/python3.11/site-packages/specfile/specfile.py", line 541, in getter
    with self.tags() as tags:
         ^^^^^^^^^^^
  File "/home/danyspin97/.local/lib/python3.11/site-packages/specfile/context_management.py", line 132, in __call__
    self.values[key] = next(self.generators[key])
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/danyspin97/.local/lib/python3.11/site-packages/specfile/specfile.py", line 275, in tags
    tags = Tags.parse(section, context=self)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/danyspin97/.local/lib/python3.11/site-packages/specfile/tags.py", line 508, in parse
    lines = process_conditions(list(section), macro_definitions, context)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/danyspin97/.local/lib/python3.11/site-packages/specfile/conditions.py", line 119, in process_conditions
    result.append((line, branches[-2]))
                         ~~~~~~~~^^^^
IndexError: list index out of range

I'll try to have a look soon, I am posting in case anyone else has the same issue.

dcermak commented 4 weeks ago

I finally got around to look at this and my current guess is that this is a bug in the upstream specfile module. It probably cannot handle the openSUSE Python packaging magic.