{"record":{"id":"3f770283b30a69e1","repo":"neoclide/coc.nvim","slug":"failed-to-resolve-link-target","errorCode":null,"errorMessage":"Failed to resolve link target","messagePattern":"Failed to resolve link target","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/handler/links.ts","lineNumber":127,"sourceCode":"      if (start <= pos.character && start + arr[0].length >= pos.character) {\n        link = DocumentLink.create(Range.create(pos.line, start, pos.line, start + arr[0].length), arr[0])\n        break\n      }\n    }\n    return link\n  }\n\n  public async openCurrentLink(): Promise<boolean> {\n    let link = await this.getCurrentLink()\n    if (link) {\n      await this.openLink(link)\n      return true\n    }\n    return false\n  }\n\n  public async openLink(link: DocumentLink): Promise<void> {\n    if (!link.target) throw new Error(`Failed to resolve link target`)\n    await workspace.openResource(link.target)\n  }\n\n  public getBuffer(bufnr: number): LinkBuffer | undefined {\n    return this.buffers.getItem(bufnr)\n  }\n\n  private cancel(): void {\n    if (this.tokenSource) {\n      this.tokenSource.cancel()\n      this.tokenSource = null\n    }\n  }\n\n  public dispose(): void {\n    disposeAll(this.disposables)\n  }\n}","sourceCodeStart":109,"sourceCodeEnd":145,"githubUrl":"https://github.com/neoclide/coc.nvim/blob/50e974d9692461a69147d5cab146a8d3e439abe4/src/handler/links.ts#L109-L145","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"null","handlingStrategy":"try-catch","validationCode":"// only attempt to open links that already carry a target\nconst link = links?.find(l => contains(l.range, cursorRange))\nif (!link?.target) return","typeGuard":null,"tryCatchPattern":"try {\n  await coc.commands.executeCommand('document.openLink')\n} catch (e) {\n  if (String(e?.message).includes('Failed to resolve link target'))\n    return vim.notify('Link target could not be resolved by the server')\n  throw e\n}","preventionTips":["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"],"tags":["lsp","document-link","unresolved-target","coc-nvim"],"backgroundTag":"unresolved-lsp-document-link","analyzedSha":"50e974d9692461a69147d5cab146a8d3e439abe4","analyzedAt":"2026-08-31T11:17:23.966Z","schemaVersion":2},"datasetVersion":"2026-09-01T08:17:40.651Z"}