{"record":{"id":"86421ba02b8c1324","repo":"yarnpkg/yarn","slug":"invalid-gist-fragment-0","errorCode":null,"errorMessage":"Invalid gist fragment $0.","messagePattern":"Invalid gist fragment \\$0\\.","errorType":"validation","errorClass":"MessageError","httpStatus":null,"severity":"error","filePath":"src/resolvers/exotics/gist-resolver.js","lineNumber":22,"sourceCode":"import type {Manifest} from '../../types.js';\nimport type PackageRequest from '../../package-request.js';\nimport {MessageError} from '../../errors.js';\nimport GitResolver from './git-resolver.js';\nimport ExoticResolver from './exotic-resolver.js';\nimport * as util from '../../util/misc.js';\n\nexport function explodeGistFragment(fragment: string, reporter: Reporter): {id: string, hash: string} {\n  fragment = util.removePrefix(fragment, 'gist:');\n\n  const parts = fragment.split('#');\n\n  if (parts.length <= 2) {\n    return {\n      id: parts[0],\n      hash: parts[1] || '',\n    };\n  } else {\n    throw new MessageError(reporter.lang('invalidGistFragment', fragment));\n  }\n}\n\nexport default class GistResolver extends ExoticResolver {\n  static protocol = 'gist';\n\n  constructor(request: PackageRequest, fragment: string) {\n    super(request, fragment);\n\n    const {id, hash} = explodeGistFragment(fragment, this.reporter);\n    this.id = id;\n    this.hash = hash;\n  }\n\n  id: string;\n  hash: string;\n\n  resolve(): Promise<Manifest> {","sourceCodeStart":4,"sourceCodeEnd":40,"githubUrl":"https://github.com/yarnpkg/yarn/blob/c2dda503f3759b5be5f0e24ecd9cf5c97a540147/src/resolvers/exotics/gist-resolver.js#L4-L40","documentation":"explodeGistFragment() splits a gist: fragment by '#'. If more than two parts result (more than one hash delimiter), the fragment is invalid. The valid format is gist:<id> or gist:<id>#<hash>.","triggerScenarios":"A dependency string like 'gist:abc#def#ghi' containing multiple '#' characters. Validated in the constructor of GistResolver via explodeGistFragment.","commonSituations":"Typos in gist dependency URLs; copy-paste errors appending extra fragments; mistaking the hash for a path separator.","solutions":["Use the format gist:<id> or gist:<id>#<commit-hash>","Remove any extra '#' characters from the gist dependency string","Verify the gist id and optional commit hash are the only segments"],"exampleFix":"// before\n\"my-dep\": \"gist:deadbeef#feature#x\"\n// after\n\"my-dep\": \"gist:deadbeef#abc123commit\"","handlingStrategy":"validation","validationCode":"function isValidGistFragment(fragment: string): boolean {\n  const cleaned = fragment.replace(/^gist:/, '');\n  return cleaned.split('#').length <= 2;\n}","typeGuard":"function isWellFormedGist(fragment: string): boolean {\n  const parts = fragment.replace(/^gist:/, '').split('#');\n  return parts.length <= 2 && parts[0].length > 0;\n}","tryCatchPattern":null,"preventionTips":["Format gist dependencies as gist:<id> or gist:<id>#<hash>","Avoid multiple '#' delimiters in dependency strings","Validate exotic fragments before adding them to package.json"],"tags":["gist","exotic-resolver","fragment"],"backgroundTag":null,"analyzedSha":"c2dda503f3759b5be5f0e24ecd9cf5c97a540147","analyzedAt":"2026-08-13T04:17:06.305Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}