{"record":{"id":"333954ccdc19978d","repo":"pockethub/PocketHub","slug":"reference-does-not-have-associated-commit-sha-1","errorCode":null,"errorMessage":"Reference does not have associated commit SHA-1","messagePattern":"Reference does not have associated commit SHA-1","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"app/src/main/java/com/github/pockethub/android/core/code/RefreshTreeTask.java","lineNumber":80,"sourceCode":"        this.repo = repository;\n        this.reference = reference;\n    }\n\n    private boolean isValidRef(GitReference ref) {\n        return ref != null && ref.object() != null\n                && !TextUtils.isEmpty(ref.object().sha());\n    }\n\n    private Single<GitReference> getValidRef(GitService service, GitReference ref, String branch) {\n        if (!isValidRef(ref)) {\n            return service.getGitReference(repo.owner().login(), repo.name(), branch)\n                    .map(response -> {\n                        if (response.isSuccessful()) {\n                            GitReference fetchedRef = response.body();\n                            if (isValidRef(fetchedRef)) {\n                                return fetchedRef;\n                            } else {\n                                throw new IOException(\"Reference does not have associated commit SHA-1\");\n                            }\n                        } else {\n                            throw new IOException(\"Request for Git Reference was unsuccessful\");\n                        }\n                    });\n        }\n\n        return Single.just(ref);\n    }\n\n    private Single<String> getBranch(GitReference ref) {\n        String branch = RefUtils.getPath(ref);\n        if (branch == null) {\n            branch = repo.defaultBranch();\n            if (TextUtils.isEmpty(branch)) {\n                return ServiceGenerator\n                        .createService(context, RepositoryService.class)\n                        .getRepository(repo.owner().login(), repo.name())","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/pockethub/PocketHub/blob/8228cb8f7197a7c2227e67ee48a2c8dc843fb553/app/src/main/java/com/github/pockethub/android/core/code/RefreshTreeTask.java#L62-L98","documentation":"getValidRef() fetches a GitReference from the GitHub API and validates that it carries an object SHA-1 via isValidRef(). If the response body parses but the ref has no associated commit SHA (e.g. a symbolic/unresolvable ref), it throws this IOException. It signals an unexpected/invalid API payload rather than a network failure.","triggerScenarios":"GET of a branch/tag ref returns HTTP 200 but the returned GitReference has a null or malformed object SHA — e.g. ref points at an object type other than a commit, or the API returns a partial body.","commonSituations":"Repository with an empty branch, renamed/deleted branch still referenced, tag pointing at a blob/tree, or API schema changes (GitHub returns ref without commit object).","solutions":["Verify the branch/tag actually exists and points to a commit (check via web UI or 'git ls-remote').","Inspect isValidRef() and the ref payload; confirm the object type is 'commit'.","Handle the IOException in the RxJava error consumer and fall back to a default ref (e.g. default branch).","Refresh/re-fetch after repo changes; the ref may have been deleted concurrently."],"exampleFix":"// before\nref = task.getValidRef(repo, refName).blockingGet();\n// after\nGitReference fetchedRef;\ntry {\n    fetchedRef = task.getValidRef(repo, refName).blockingGet();\n} catch (IOException e) {\n    fetchedRef = task.getValidRef(repo, repo.getDefaultBranch()).blockingGet();\n}","handlingStrategy":"retry","validationCode":"// verify ref exists via ls-remote or API before use:\n// git ls-remote origin refs/heads/<branch>","typeGuard":"fun isValidRef(ref: GitReference?): Boolean =\n    ref?.`object`?.sha?.isNotEmpty() == true","tryCatchPattern":"try {\n    single.blockingGet()\n} catch (IOException e) {\n    // fall back to default branch\n}","preventionTips":["Validate ref object SHA before consuming","Retry transient failures with backoff","Fall back to default branch on invalid ref","Monitor for GitHub API schema changes"],"tags":["github-api","git-reference","network","invalid-response"],"backgroundTag":"unexpected-api-response-shape","analyzedSha":"8228cb8f7197a7c2227e67ee48a2c8dc843fb553","analyzedAt":"2026-09-11T10:16:17.606Z","contentChangedAt":"2026-09-11T10:16:17.606Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}