debugger: Fall back to cached adapter binaries when offline (#50928)
Nihal Kumar
created
The Python (debugpy) and Go (delve-shim-dap) debug adapters
unconditionally require network access on every debug session start —
even when the adapter binary is already cached locally. This makes the
debugger completely unusable offline.
Python: fetch_debugpy_whl → maybe_fetch_new_wheel hits pypi; failure
propagates as a fatal error.
Go: install_shim → fetch_latest_adapter_version hits the GitHub API;
failure propagates as a fatal error.
CodeLLDB and JavaScript adapters already handle this correctly.
Fix for Python and Go:
Wrap the network fetch in each adapter with a fallback: if the request
fails and a previously downloaded adapter exists on disk, log a warning
and use the cached version. If no cache exists, the original error
propagates unchanged.
Logs after the fix:
```
2026-03-06T16:31:51+05:30 WARN [dap_adapters::python] Failed to fetch latest debugpy, using cached version: getting latest release
2026-03-06T16:31:51+05:30 INFO [dap::transport] Debug adapter has connected to TCP server 127.0.0.1:45533
```
Limitations:
The debugger must be run at least once with internet connectivity to
populate the cache on disk. This PR does not change that requirement.
Closes #45781
Before you mark this PR as ready for review, make sure that you have:
- [ ] Added a solid test coverage and/or screenshots from doing manual
testing
- No automated tests are included. The existing MockDelegate stubs
http_client() and fs() as unimplemented!(), so testing the fallback path
would require new mock infrastructure. The fix was verified manually by
running the debug build offline with and without cached adapters. The
CodeLLDB adapter's equivalent fallback (lines 357-374) also has no
dedicated test.
- [x] Done a self-review taking into account security and performance
aspects
Release Notes:
- Fixed debugger failing to start when offline if a debug adapter was
previously downloaded.