rust-lang/rust · error · anyhow::Error
Invalid LSP resolve data
Error message
Invalid LSP resolve data
What it means
Raised by handle_inlay_hints_resolve via ensure! when the file_id carried in the InlayHintResolveData refers to a file the GlobalStateSnapshot no longer knows about (snap.file_exists(file_id) is false). The resolve data was stale and pointed at a deleted/never-loaded file.
Source
Thrown at src/tools/rust-analyzer/crates/rust-analyzer/src/handlers/request.rs:1861
pub(crate) fn handle_inlay_hints_resolve(
snap: GlobalStateSnapshot,
mut original_hint: InlayHint,
) -> anyhow::Result<InlayHint> {
let _p = tracing::info_span!("handle_inlay_hints_resolve").entered();
let Some(data) = original_hint.data.take() else {
return Ok(original_hint);
};
let resolve_data: lsp_ext::InlayHintResolveData = serde_json::from_value(data)?;
let file_id = FileId::from_raw(resolve_data.file_id);
if resolve_data.version != snap.file_version(file_id) {
tracing::warn!("Inlay hint resolve data is outdated");
return Ok(original_hint);
}
let Some(hash) = resolve_data.hash.parse().ok() else {
return Ok(original_hint);
};
anyhow::ensure!(snap.file_exists(file_id), "Invalid LSP resolve data");
let line_index = snap.file_line_index(file_id)?;
let range = from_proto::text_range(&line_index, resolve_data.resolve_range)?;
let mut forced_resolve_inlay_hints_config = snap.config.inlay_hints(snap.minicore());
forced_resolve_inlay_hints_config.fields_to_resolve = InlayFieldsToResolve::empty();
let resolve_hints = snap.analysis.inlay_hints_resolve(
&forced_resolve_inlay_hints_config,
file_id,
range,
hash,
|hint| {
std::hash::BuildHasher::hash_one(
&std::hash::BuildHasherDefault::<ide_db::FxHasher>::default(),
hint,
)
},
)?;View on GitHub (pinned to 7088e4b63a)
Solutions
- On the client side, invalidate cached inlay hints when files change or the workspace is reloaded, and re-request hints rather than resolving stale ones.
- If you control the client, treat resolve failures by re-issuing textDocument/inlayHint for the visible range.
- Server-side, consider returning Ok(original_hint) instead of erroring for missing files to match the version-mismatch path's resilience.
Example fix
// before: hard error on a missing file
anyhow::ensure!(snap.file_exists(file_id), "Invalid LSP resolve data");
// after: degrade gracefully like the stale-version branch above it
if !snap.file_exists(file_id) {
tracing::warn!("Inlay hint resolve references an unknown file_id {file_id}");
return Ok(original_hint);
} Defensive patterns
Strategy: fallback
Validate before calling
// Client-side: invalidate cached inlay hints on file/version changes so you // never resolve against a file_id the server has forgotten. on DidChangeWatchedFiles / workspace reload => clear hintCache.clear(); on visible range refresh => re-request textDocument/inlayHint instead of resolving stale hints.
Type guard
null
Try / catch
// Server-side resilience: treat a missing file like the stale-version case:
if !snap.file_exists(file_id) {
tracing::warn!("inlay hint resolve references unknown file {file_id}");
return Ok(original_hint); // graceful degradation instead of an LSP error
} Prevention
- Invalidate cached hints on file delete/rename and workspace reload.
- Re-request hints rather than resolving stale data after reloads.
- Server-side, prefer Ok(original_hint) over ensure! for transient stale references.
When it happens
Trigger: A client sends an inlayHint/resolve request whose data field encodes a file_id that the server has since evicted or never loaded — file deleted from disk, workspace reloaded, or the hint originated from a stale version. Unlike version/hash mismatches (which return Ok gracefully), a missing file is treated as a hard error.
Common situations: Client retries an old resolve after a workspace reload; the file was deleted between hint computation and resolve; a third-party client cached hints across restarts.
Related errors
- client exited without proper shutdown sequence
- A receiver has been dropped, something panicked!
- rust-analyzer Language Server is not available. Please, ensu
- Failed to execute ${path} --version.
- bootstrap error. See the logs in "OUTPUT > Rust Analyzer Cli
AI-assisted analysis of rust-lang/rust@7088e4b63a (2026-08-10).
Data as JSON: /api/errors/b3b04db6ce1e590f.
Report an issue: GitHub.