{"record":{"id":"c19067dfe3c4e4c9","repo":"badges/shields","slug":"directory-not-found","errorCode":null,"errorMessage":"directory not found","messagePattern":"directory not found","errorType":"validation","errorClass":"InvalidParameter","httpStatus":400,"severity":"error","filePath":"services/github/github-directory-file-count.service.js","lineNumber":151,"sourceCode":"\n    if (type) {\n      const objectType = type === 'dir' ? 'tree' : 'blob'\n      files = files.filter(file => file.type === objectType)\n    }\n\n    if (extension) {\n      files = files.filter(file => file.extension === `.${extension}`)\n    }\n\n    return {\n      count: files.length,\n    }\n  }\n\n  async handle({ user, repo, path }, { type, extension }) {\n    const json = await this.fetch({ user, repo, path })\n    if (json.data.repository.object === null) {\n      throw new InvalidParameter({\n        prettyMessage: 'directory not found',\n      })\n    }\n    const content = json.data.repository.object.entries\n    const { count } = this.constructor.transform(content, { type, extension })\n    return this.constructor.render({ count })\n  }\n}\n","sourceCodeStart":133,"sourceCodeEnd":160,"githubUrl":"https://github.com/badges/shields/blob/766fd8bc89a90b8534dc573ab72dec30215ab1ec/services/github/github-directory-file-count.service.js#L133-L160","documentation":"handle() fetches the directory via GraphQL and throws InvalidParameter 'directory not found' when `repository.object` is null. GitHub resolved the user/repo but the requested path/ref does not match any object, so the directory cannot be found. Unlike error 105 this means the path doesn't exist at all, rather than existing as a file.","triggerScenarios":"Requesting directory-file-count where `path` names a folder that doesn't exist on the given branch/ref (deleted, renamed, or never created), so GraphQL's object on that path is null.","commonSituations":"Repository restructure (src/ moved or renamed to lib/) leaving badges stale; wrong branch param where the folder only exists on another branch; case-sensitivity mismatches in the path.","solutions":["Verify the folder exists at that exact path on the requested branch (browse it on github.com).","Update the badge path after repository restructures/renames.","Check for case mismatches — GitHub paths are case-sensitive."],"exampleFix":"// before\n/service/github/directory-file-count/user/repo/lib.json  (repo uses src/)\n// after\n/service/github/directory-file-count/user/repo/src.json","handlingStrategy":"validation","validationCode":"// confirm directory exists on the target branch\nconst res = await fetch(`https://api.github.com/repos/OWNER/REPO/contents/${path}?ref=${branch}`);\nif (res.status === 404) throw new Error(`directory '${path}' not found on branch '${branch}'`);","typeGuard":"function isNonNullObject(obj) {\n  return obj != null && typeof obj === 'object' && ('entries' in obj ? Array.isArray(obj.entries) : true);\n}","tryCatchPattern":"try {\n  const { count } = await getDirectoryFileCount({ user, repo, path });\n} catch (e) {\n  if (e.prettyMessage === 'directory not found') {\n    // correct the path/branch or hide the badge\n  } else throw e;\n}","preventionTips":["Browse the path on github.com before wiring a badge to it.","Remember paths are case-sensitive.","Update badge paths after folder renames or branch deletions."],"tags":["github","invalid-parameter","directory-not-found","path"],"backgroundTag":"directory-not-found","analyzedSha":"766fd8bc89a90b8534dc573ab72dec30215ab1ec","analyzedAt":"2026-08-30T01:40:27.499Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}