Skip to content

Commit ddd1052

Browse files
committed
fix: normalize repoFullName to lowercase in validateRepoFullName
Admin endpoints treated repoFullName as case-sensitive even though GitHub repository identity is case-insensitive. registerRepo did an exact-case update match that failed silently when request casing differed from stored row casing (e.g. 'Entrius/das-github-mirror' vs 'entrius/das-github-mirror'). Add .toLowerCase() to validateRepoFullName so all incoming values are normalized at the entry point before any persistence or lookup. This covers both the backfill and registerRepo endpoints which both call validateRepoFullName. Fixes #1214 fix: use LOWER() comparison for case-insensitive repoFullName matching Input-only normalization (.toLowerCase()) misses repos stored with GitHub's canonical casing. Storage keeps the original case from installation.handler.ts so lowercasing the input causes registerRepo's update and getTokenForRepo's findOneBy to miss rows for any repo whose stored name has uppercase characters. Apply the same LOWER(repo_full_name) = LOWER(:repoFullName) pattern already used in repos.service.ts and pulls.service.ts: - registerRepo: createQueryBuilder update with LOWER() WHERE clause - getTokenForRepo: createQueryBuilder select with LOWER() WHERE clause Fixes #1214
1 parent 44604b5 commit ddd1052

2 files changed

Lines changed: 12 additions & 5 deletions

File tree

packages/das/src/api/admin.controller.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,12 @@ export class AdminController {
123123
}> {
124124
const repoFullName = validateRepoFullName(body?.repoFullName);
125125

126-
const result = await this.repoRepo.update(
127-
{ repoFullName },
128-
{ registered: true },
129-
);
126+
const result = await this.repoRepo
127+
.createQueryBuilder()
128+
.update()
129+
.set({ registered: true })
130+
.where("LOWER(repo_full_name) = LOWER(:repoFullName)", { repoFullName })
131+
.execute();
130132

131133
if (!result.affected) {
132134
throw new NotFoundException(

packages/das/src/webhook/github-fetcher.service.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,12 @@ export class GitHubFetcherService implements OnModuleInit {
190190
}
191191

192192
private async getTokenForRepo(repoFullName: string): Promise<string> {
193-
const repo = await this.repoRepo.findOneBy({ repoFullName });
193+
const repo = await this.repoRepo
194+
.createQueryBuilder("repo")
195+
.where("LOWER(repo.repo_full_name) = LOWER(:repoFullName)", {
196+
repoFullName,
197+
})
198+
.getOne();
194199
if (!repo?.installationId) {
195200
throw new Error(`No installation for repo ${repoFullName}`);
196201
}

0 commit comments

Comments
 (0)