neoclide/coc.nvim · error · Error
Failed to resolve link target
Error message
Failed to resolve link target
What it means
openLink throws when a DocumentLink has no resolved `target` — the language server returned a link whose target was meant to be resolved lazily via `document/linkResolve`, and resolution either was not performed or returned nothing. coc.nvim refuses to open an undefined URI.
Source
Thrown at src/handler/links.ts:127
if (start <= pos.character && start + arr[0].length >= pos.character) {
link = DocumentLink.create(Range.create(pos.line, start, pos.line, start + arr[0].length), arr[0])
break
}
}
return link
}
public async openCurrentLink(): Promise<boolean> {
let link = await this.getCurrentLink()
if (link) {
await this.openLink(link)
return true
}
return false
}
public async openLink(link: DocumentLink): Promise<void> {
if (!link.target) throw new Error(`Failed to resolve link target`)
await workspace.openResource(link.target)
}
public getBuffer(bufnr: number): LinkBuffer | undefined {
return this.buffers.getItem(bufnr)
}
private cancel(): void {
if (this.tokenSource) {
this.tokenSource.cancel()
this.tokenSource = null
}
}
public dispose(): void {
disposeAll(this.disposables)
}
}View on GitHub (pinned to 50e974d969)
Solutions
- Update the language server; unresolved links that fail to resolve are usually a server bug.
- Check the server's output log (`:CocCommand workspace.showOutput`) for errors on the `documentLink/resolve` request.
- Report the missing resolved target to the server's repository with the specific document/link.
- Use an alternative navigation (e.g. `gd` or `:CocDefinition`) for the same symbol.
Example fix
null
Defensive patterns
Strategy: try-catch
Validate before calling
// only attempt to open links that already carry a target const link = links?.find(l => contains(l.range, cursorRange)) if (!link?.target) return
Try / catch
try {
await coc.commands.executeCommand('document.openLink')
} catch (e) {
if (String(e?.message).includes('Failed to resolve link target'))
return vim.notify('Link target could not be resolved by the server')
throw e
} Prevention
- Prefer resolution-aware navigation when the server uses unresolved links
- Update language servers that emit links failing documentLink/resolve
- Fall back to coc-definition when link targets are missing
When it happens
Trigger: Calling `:CocCommand document.openLink` (via openCurrentLink) on a link whose `link.target` is undefined because the server only provides a range and expects the client to call the linkResolve callback, and resolution failed or returned an empty result.
Common situations: Language servers that use unresolved document links (target resolved on demand) when the resolve request fails or returns null; hovering/opening a link in a buffer where the server emitted placeholder links.
Related errors
- Inlay hint provider not found for current document
- Filetype "${this.doc.filetype}" not enabled by inlayHint con
- Rename provider not found for current buffer
- Provider returns null on prepare, unable to rename at curren
- Provider returns null for rename edits.
AI-assisted analysis of neoclide/coc.nvim@50e974d969 (2026-08-31).
Data as JSON: /api/errors/3f770283b30a69e1.
Report an issue: GitHub.