Personal Telegram developer console for GitHub
fix: fallback private repository id navigation
davoodmehraban89 committed
Oct 4, 2026 at 06:35 UTC
a825a91b561d8702005d21d4a5ff3760fc26154a
1 file changed
+18
-3
src/github.js
+18
-3
@@ -75,7 +75,9 @@ export class GitHubService {
75
if (allowNotFound && res.status === 404) return null;
76
const providerMessage = parsed?.message || raw.slice(0, 240);
77
const detail = providerMessage ? ` ${providerMessage}` : '';
78
- throw new Error(`${label} failed: ${res.status}${detail}`);
78
+ const error = new Error(`${label} failed: ${res.status}${detail}`);
79
+ error.status = res.status;
80
+ throw error;
81
}
82
if (allowEmpty) return { accepted: true, status: res.status };
83
if (!raw) return null;
@@ -110,8 +112,21 @@ export class GitHubService {
112
}
113
114
async getRepositoryContext(repoRef) {
113
- const raw = await this.requestJson(this.repositoryLookupUrl(repoRef), 'GitHub repository');
114
- return { raw, apiBase: this.repositoryApiBase(raw.full_name) };
115
+ const value = String(repoRef || '');
116
+ try {
117
+ const raw = await this.requestJson(this.repositoryLookupUrl(value), 'GitHub repository');
118
+ return { raw, apiBase: this.repositoryApiBase(raw.full_name) };
119
+ } catch (error) {
120
+ if (!/^\d+$/.test(value) || error?.status !== 404) throw error;
121
+
122
+ const repositories = await this.listRepositories();
123
+ const match = repositories.find(repo => repo.id === value);
124
+ if (!match?.fullName) throw error;
125
+
126
+ const apiBase = this.repositoryApiBase(match.fullName);
127
+ const raw = await this.requestJson(apiBase, 'GitHub repository');
128
+ return { raw, apiBase: this.repositoryApiBase(raw.full_name) };
129
+ }
130
}
131
132
mapRepository(r) {