fix: fallback to legacy API for private dataset/model info#3
Conversation
The OpenAPI GET /datasets/{owner}/{name} endpoint returns 404 for
private datasets even with a valid Bearer token. The legacy API with
cookie-based session auth handles private repos correctly. Add a
fallback: on NotExistError from OpenAPI, retry via the legacy client.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Code Review
This pull request introduces a fallback mechanism when retrieving repository metadata. Specifically, it adds a get_repo_info method to the legacy API that utilizes cookie-based session auth to support private repositories. In the main API, calls to fetch models or datasets via the OpenAPI client now catch NotExistError and fall back to this legacy endpoint. The reviewer suggested refactoring the duplicate try-except blocks for models and datasets into a single block to reduce code duplication.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| if rt is RepoType.MODEL: | ||
| data = self.openapi.get_model(owner, name) | ||
| try: | ||
| data = self.openapi.get_model(owner, name) | ||
| except NotExistError: | ||
| data = self.legacy.get_repo_info(repo_id, str(rt)) | ||
| elif rt is RepoType.DATASET: | ||
| data = self.openapi.get_dataset(owner, name) | ||
| try: | ||
| data = self.openapi.get_dataset(owner, name) | ||
| except NotExistError: | ||
| data = self.legacy.get_repo_info(repo_id, str(rt)) |
There was a problem hiding this comment.
The try-except blocks for RepoType.MODEL and RepoType.DATASET are identical except for the specific OpenAPI method called. We can simplify this and reduce code duplication by grouping them together.
| if rt is RepoType.MODEL: | |
| data = self.openapi.get_model(owner, name) | |
| try: | |
| data = self.openapi.get_model(owner, name) | |
| except NotExistError: | |
| data = self.legacy.get_repo_info(repo_id, str(rt)) | |
| elif rt is RepoType.DATASET: | |
| data = self.openapi.get_dataset(owner, name) | |
| try: | |
| data = self.openapi.get_dataset(owner, name) | |
| except NotExistError: | |
| data = self.legacy.get_repo_info(repo_id, str(rt)) | |
| if rt in (RepoType.MODEL, RepoType.DATASET): | |
| try: | |
| data = ( | |
| self.openapi.get_model(owner, name) | |
| if rt is RepoType.MODEL | |
| else self.openapi.get_dataset(owner, name) | |
| ) | |
| except NotExistError: | |
| data = self.legacy.get_repo_info(repo_id, str(rt)) |
The OpenAPI GET /datasets/{owner}/{name} endpoint returns 404 for private datasets even with a valid Bearer token. The legacy API with cookie-based session auth handles private repos correctly. Add a fallback: on NotExistError from OpenAPI, retry via the legacy client.