Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

VSCode Extension: Request textDocument/documentSymbol failed

Aperta
#1,308 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
42/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
python, vscode
Ambito
devtools

Direzione di ricerca

Inizia in hamilton_lsp/server.py dal punto di ingresso document_symbols e riproduci la richiesta textDocument/documentSymbol usando il traceback OSError mostrato. Traccia il motivo per cui inspect.getsourcelines non riesce a ottenere il codice sorgente per alcuni nodi, quindi verifica che la modifica non produca più errori ripetuti nelle richieste di VS Code e che il comportamento previsto di logging o workaround sia coperto.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

triage vscode

The VS Code extension keeps popping up an error ~dialog/toast with the message Request textDocument/documentSymbol failed.

Current behavior

  • Using my large, proprietary codebase, edit some files, error dialog pops up on every keypress.
  • If I dismiss it, it comes right back.
  • Choosing the VS Code option to hide "Info & Warning" messages from the extension does not help, presumably because this is an error.

Screenshots

Image

Library & System Information

python v3.11.10
macOS 15.3.1
VS Code 1.100.0 (and Cursor 0.50.4)
Hamilton VSCode extension v0.1.2
Python libraries installed in venv:

Package                      Version        Editable project location
---------------------------- -------------- ------------------------------
aiofiles                     24.1.0
aiohappyeyeballs             2.6.1
aiohttp                      3.11.18
aiosignal                    1.3.2
annotated-types              0.7.0
anyio                        4.8.0
appnope                      0.1.4
argon2-cffi                  23.1.0
argon2-cffi-bindings         21.2.0
arrow                        1.3.0
asgiref                      3.8.1
asttokens                    3.0.0
async-lru                    2.0.4
attrs                        25.3.0
babel                        2.16.0
backoff                      2.2.1
beautifulsoup4               4.12.3
bleach                       6.2.0
blinker                      1.9.0
cattrs                       24.1.3
certifi                      2024.12.14
cffi                         1.17.1
cfgv                         3.4.0
charset-normalizer           3.4.1
click                        8.2.0
colorlog                     6.9.0
comm                         0.2.2
contourpy                    1.3.1
cryptography                 44.0.0
cycler                       0.12.1
dash                         2.17.0
dash-bootstrap-components    1.6.0
dash-core-components         2.0.0
dash-html-components         2.0.0
dash-table                   5.0.0
testproj                     0.1            /Users/gkistner/testproj
testproj-toolkit             0.11
debugpy                      1.8.11
decorator                    5.1.1
defusedxml                   0.7.1
distlib                      0.3.9
distro                       1.9.0
django                       5.2
django-extensions            4.1
django-ninja                 1.4.1
duckdb                       1.2.2
et-xmlfile                   2.0.0
executing                    2.1.0
fastjsonschema               2.21.1
filelock                     3.18.0
flask                        3.0.3
flexcache                    0.3
flexparser                   0.4
fonttools                    4.55.3
fqdn                         1.5.1
frozenlist                   1.6.0
fsspec                       2025.3.2
gitdb                        4.0.12
gitpython                    3.1.44
graphviz                     0.20.3
h11                          0.14.0
httpcore                     1.0.7
httpx                        0.28.1
identify                     2.6.10
idna                         3.10
importlib-metadata           8.5.0
iniconfig                    2.0.0
ipykernel                    6.29.5
ipython                      8.31.0
ipywidgets                   8.1.3
isoduration                  20.11.0
itsdangerous                 2.2.0
jedi                         0.19.2
jinja2                       3.1.5
json5                        0.10.0
jsonpointer                  3.0.0
jsonschema                   4.23.0
jsonschema-specifications    2024.10.1
jupyter-client               8.6.3
jupyter-collaboration        2.1.0
jupyter-core                 5.7.2
jupyter-events               0.11.0
jupyter-http-over-ws         0.0.8
jupyter-lsp                  2.2.5
jupyter-server               2.15.0
jupyter-server-fileid        0.9.3
jupyter-server-terminals     0.5.3
jupyter-ydoc                 2.0.1
jupyterlab                   4.2.0
jupyterlab-pygments          0.3.0
jupyterlab-server            2.27.3
jupyterlab-widgets           3.0.13
kiwisolver                   1.4.8
loguru                       0.7.3
lsprotocol                   2023.0.1
markdown-it-py               3.0.0
markupsafe                   3.0.2
matplotlib                   3.7.0
matplotlib-inline            0.1.7
mdurl                        0.1.2
mistune                      3.1.0
monotonic                    1.6
msal                         1.31.1
multidict                    6.4.3
mypy-extensions              1.0.0
nbclient                     0.10.2
nbconvert                    7.16.5
nbformat                     5.10.4
nest-asyncio                 1.6.0
networkx                     2.8.4
nodeenv                      1.9.1
notebook                     7.2.3
notebook-shim                0.2.4
ntlm-auth                    1.5.0
numpy                        1.23.5
office365-rest-python-client 2.5.10
openpyxl                     3.0.10
overrides                    7.7.0
packaging                    24.2
pandas                       1.5.3
pandocfilters                1.5.1
parso                        0.8.4
passlib                      1.7.4
pdoc                         15.0.1
pexpect                      4.9.0
pillow                       11.1.0
pint                         0.24.4
platformdirs                 4.3.6
plotly                       5.22.0
pluggy                       1.5.0
posthog                      3.25.0
pre-commit                   4.2.0
prometheus-client            0.21.1
prompt-toolkit               3.0.48
propcache                    0.3.1
psutil                       6.1.1
psycopg                      3.2.5
psycopg-binary               3.2.5
psycopg2-binary              2.9.10
ptyprocess                   0.7.0
pure-eval                    0.2.3
pyclean                      3.1.0
pycparser                    2.22
pycrdt                       0.8.31
pycrdt-websocket             0.13.5
pydantic                     2.11.4
pydantic-core                2.33.2
pydantic-yaml                1.4.0
pygls                        1.3.1
pygments                     2.19.1
pyjwt                        2.10.1
pyparsing                    3.2.1
pyproject-fmt                2.5.1
pytest                       8.3.5
pytest-order                 1.3.0
python-dateutil              2.9.0.post0
python-json-logger           3.2.1
pytz                         2024.2
pyyaml                       6.0.2
pyzmq                        26.2.0
referencing                  0.35.1
requests                     2.32.3
requests-ntlm2               6.5.2
retrying                     1.3.4
rfc3339-validator            0.1.4
rfc3986-validator            0.1.1
rich                         14.0.0
rpds-py                      0.22.3
ruamel-yaml                  0.18.10
ruamel-yaml-clib             0.2.12
ruff                         0.11.9
scipy                        1.10.0
seaborn                      0.12.2
send2trash                   1.8.3
setuptools                   75.8.0
sf-hamilton                  1.88.0
sf-hamilton-lsp              0.1.0
sf-hamilton-sdk              0.8.0
sf-hamilton-ui               0.0.17
shellingham                  1.5.4
six                          1.17.0
smmap                        5.0.2
snakeviz                     2.2.2
sniffio                      1.3.1
soupsieve                    2.6
sqlglot                      26.15.0
sqlite-anyio                 0.2.3
sqlparse                     0.5.3
stack-data                   0.6.3
tabulate2                    1.10.1
tenacity                     9.0.0
terminado                    0.18.1
tinycss2                     1.4.0
toml-fmt-common              1.0.1
tornado                      6.4.2
traitlets                    5.14.3
typer                        0.15.2
types-python-dateutil        2.9.0.20241206
typing-extensions            4.12.2
typing-inspect               0.9.0
typing-inspection            0.4.0
tzlocal                      2.1
uncertainties                3.2.3
uri-template                 1.3.0
urllib3                      2.3.0
virtualenv                   20.30.0
wcwidth                      0.2.13
webcolors                    24.11.1
webencodings                 0.5.1
websocket-client             1.8.0
werkzeug                     3.0.6
widgetsnbextension           4.0.13
yarl                         1.20.0
zipp                         3.21.0

Expected behavior

Change logging level to warning or info, or more cleanly workaround this problem.

Additional context

Here's the Output pane for the Hamilton Language Server, cleaned right before triggering this error:

2025-05-15 15:10:00.127 [info] Failed to hash source code for node pcie_result. Certain environments (such as databricks) do not allow it. In this case, version will be None.

2025-05-15 15:10:00.127 [info] Failed to hash source code for node config_name. Certain environments (such as databricks) do not allow it. In this case, version will be None.

2025-05-15 15:10:00.127 [info] Failed to hash source code for node cpu_name. Certain environments (such as databricks) do not allow it. In this case, version will be None.
Failed to hash source code for node foo. Certain environments (such as databricks) do not allow it. In this case, version will be None.
Failed to hash source code for node bar_name. Certain environments (such as databricks) do not allow it. In this case, version will be None.
Failed to hash source code for node gar. Certain environments (such as databricks) do not allow it. In this case, version will be None.
Failed to hash source code for node gar_per_row. Certain environments (such as databricks) do not allow it. In this case, version will be None.
Failed to hash source code for node foo_per_row. Certain environments (such as databricks) do not allow it. In this case, version will be None.
Failed to hash source code for node row_count. Certain environments (such as databricks) do not allow it. In this case, version will be None.

2025-05-15 15:10:00.180 [info] Failed to handle request 24 textDocument/documentSymbol DocumentSymbolParams(text_document=TextDocumentIdentifier(uri='file:///Users/gkistner/testproj/test.py'), work_done_token=None, partial_result_token=None)
Traceback (most recent call last):
  File "/Users/gkistner/testproj/.venv/lib/python3.11/site-packages/pygls/protocol/json_rpc.py", line 266, in _handle_request
    self._execute_request(msg_id, handler, params)
  File "/Users/gkistner/testproj/.venv/lib/python3.11/site-packages/pygls/protocol/json_rpc.py", line 188, in _execute_request
    self._send_response(msg_id, handler(params))
                                ^^^^^^^^^^^^^^^
  File "/Users/gkistner/testproj/.venv/lib/python3.11/site-packages/hamilton_lsp/server.py", line 191, in document_symbols
    _, starting_line = inspect.getsourcelines(origin)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.11.10/Frameworks/Python.framework/Versions/3.11/lib/python3.11/inspect.py", line 1240, in getsourcelines
    lines, lnum = findsource(object)
                  ^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.11.10/Frameworks/Python.framework/Versions/3.11/lib/python3.11/inspect.py", line 1077, in findsource
    raise OSError('could not get source code')
OSError: could not get source code

2025-05-15 15:10:00.181 [info] [Error - 3:10:00 PM] Request textDocument/documentSymbol failed.
2025-05-15 15:10:00.181 [info]   Message: OSError: could not get source code
  Code: -32603 
[object Object]
2025-05-15 15:10:00.475 [info] Failed to handle request 25 textDocument/documentSymbol DocumentSymbolParams(text_document=TextDocumentIdentifier(uri='file:///Users/gkistner/testproj/test.py'), work_done_token=None, partial_result_token=None)
Traceback (most recent call last):
  File "/Users/gkistner/testproj/.venv/lib/python3.11/site-packages/pygls/protocol/json_rpc.py", line 266, in _handle_request
    self._execute_request(msg_id, handler, params)
  File "/Users/gkistner/testproj/.venv/lib/python3.11/site-packages/pygls/protocol/json_rpc.py", line 188, in _execute_request
    self._send_response(msg_id, handler(params))
                                ^^^^^^^^^^^^^^^
  File "/Users/gkistner/testproj/.venv/lib/python3.11/site-packages/hamilton_lsp/server.py", line 191, in document_symbols
    _, starting_line = inspect.getsourcelines(origin)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.11.10/Frameworks/Python.framework/Versions/3.11/lib/python3.11/inspect.py", line 1240, in getsourcelines
    lines, lnum = findsource(object)
                  ^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.11.10/Frameworks/Python.framework/Versions/3.11/lib/python3.11/inspect.py", line 1077, in findsource
    raise OSError('could not get source code')
OSError: could not get source code

2025-05-15 15:10:00.476 [info] [Error - 3:10:00 PM] Request textDocument/documentSymbol failed.
2025-05-15 15:10:00.476 [info]   Message: OSError: could not get source code
  Code: -32603 
[object Object]
Lingua principale
Jupyter Notebook
Stelle
2.6k
Fork
218
Merge medio
2g 1m
PR unite (30g)
17

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di apache/hamilton

Tutte le issue di apache/hamilton

Issue simili

Altre issue su DevTools

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.