{"record":{"id":"17ac477c84959b9a","repo":"yarnpkg/yarn","slug":"hostedgitresolveerror","errorCode":null,"errorMessage":"hostedGitResolveError","messagePattern":"hostedGitResolveError","errorType":"exception","errorClass":"MessageError","httpStatus":null,"severity":"error","filePath":"src/resolvers/exotics/hosted-git-resolver.js","lineNumber":121,"sourceCode":"      queue: this.resolver.fetchingQueue,\n    });\n\n    if (out) {\n      // clean up output\n      let lines = out.trim().split('\\n');\n\n      // remove first two lines which contains compatibility info etc\n      lines = lines.slice(2);\n\n      // remove last line which contains the terminator \"0000\"\n      lines.pop();\n\n      // remove line lengths from start of each line\n      lines = lines.map((line): string => line.slice(4));\n\n      out = lines.join('\\n');\n    } else {\n      throw new Error(this.reporter.lang('hostedGitResolveError'));\n    }\n\n    return client.setRefHosted(out);\n  }\n\n  async resolveOverHTTP(url: string): Promise<Manifest> {\n    const commit = await this.getRefOverHTTP(url);\n    const {config} = this;\n\n    const tarballUrl = this.constructor.getTarballUrl(this.exploded, commit);\n\n    const tryRegistry = async (registry): Promise<?Manifest> => {\n      const {filename} = registries[registry];\n\n      const href = this.constructor.getHTTPFileUrl(this.exploded, filename, commit);\n      const file = await config.requestManager.request({\n        url: href,\n        queue: this.resolver.fetchingQueue,","sourceCodeStart":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/yarnpkg/yarn/blob/c2dda503f3759b5be5f0e24ecd9cf5c97a540147/src/resolvers/exotics/hosted-git-resolver.js#L103-L139","documentation":"In getRefOverHTTP(), if the hosted-git service's refs response does not match any of the expected git protocol formats (smart HTTP, dumb HTTP, etc.), Yarn cannot extract a commit ref and throws as a terminal fallback.","triggerScenarios":"Resolving a non-GitHub hosted-git dependency where the refs endpoint returns an unrecognized format. The else branch fires after all known format checks fail.","commonSituations":"Private or self-hosted git services with non-standard ref listing; git host API/version changes; proxies or CDNs altering the response body.","solutions":["Switch the dependency to a direct git+https:// or https:// URL","Pin to a specific commit using #<full-hash> to bypass ref discovery","Verify the git host is reachable and returns standard git refs","Check for corporate proxies intercepting the refs request"],"exampleFix":"// before\n\"my-dep\": \"bitbucket:user/repo\"\n// after\n\"my-dep\": \"git+https://bitbucket.org/user/repo.git#abc123\"","handlingStrategy":"fallback","validationCode":"// Prefer a pinned commit to avoid ref discovery entirely\nfunction shouldPinCommit(pattern: string): boolean {\n  return /#[0-9a-f]{40}$/.test(pattern);\n}","typeGuard":"function isPinnableGitUrl(pattern: string): boolean {\n  return /git\\+https?://.+#?[0-9a-f]{0,40}/.test(pattern);\n}","tryCatchPattern":"try {\n  const ref = await resolver.getRefOverHTTP(url);\n} catch (e) {\n  if (e.message.includes('hostedGitResolveError')) {\n    // fall back to a git+https URL with a pinned commit\n  }\n}","preventionTips":["Pin hosted-git dependencies to a specific commit hash","Use git+https:// URLs for non-GitHub hosts","Verify corporate proxies do not alter git ref responses"],"tags":["hosted-git","network","resolver"],"backgroundTag":null,"analyzedSha":"c2dda503f3759b5be5f0e24ecd9cf5c97a540147","analyzedAt":"2026-08-13T04:17:06.305Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}