Skip to content

fix: normalize repoFullName to lowercase in validateRepoFullName#70

Merged
anderdc merged 1 commit into
entrius:testfrom
Tet-9:fix/1214-case-insensitive-repo-fullname
May 17, 2026
Merged

fix: normalize repoFullName to lowercase in validateRepoFullName#70
anderdc merged 1 commit into
entrius:testfrom
Tet-9:fix/1214-case-insensitive-repo-fullname

Conversation

@Tet-9
Copy link
Copy Markdown
Contributor

@Tet-9 Tet-9 commented May 13, 2026

Summary

GitHub repository identity is case-insensitive, but admin endpoints
used exact-case matching. A request with Entrius/das-github-mirror
would fail to find a stored row of entrius/das-github-mirror, causing
valid repos to get "Repo not found" errors on registration and breaking
downstream backfill flows in getTokenForRepo.

Root Cause

validateRepoFullName returned the input as-is without normalization.
Both registerRepo and backfillRepo call it, so the raw casing flowed
directly into DB update and findOneBy queries.

Fix

One line — .toLowerCase() on the return value of validateRepoFullName.
Since all admin paths go through this validator, normalization is enforced
at the single entry point rather than scattered across call sites.

Fixes entrius/gittensor#1214

@xiao-xiao-mao xiao-xiao-mao Bot added the bug Something isn't working label May 13, 2026
Copy link
Copy Markdown
Collaborator

@anderdc anderdc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This lowercases the admin input but repo rows store GitHub's canonical casing — installation.handler.ts:44,52 insert repository.full_name unnormalized. For any repo whose canonical name has uppercase, lowercasing the input makes registerRepo's update({ repoFullName }) (admin.controller.ts:126) and getTokenForRepo's findOneBy({ repoFullName }) (github-fetcher.service.ts:198) miss the row — a regression on the previously-working exact-case path.

The repo already handles case-insensitive repo matching correctly in repos.service.ts:28 and pulls.service.ts:51 with LOWER(repo_full_name) = LOWER($1). Apply that same pattern to the registerRepo update and the getTokenForRepo lookup instead of normalizing input only — input-only normalization misses mixed-case repos since storage keeps canonical casing.

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
@Tet-9 Tet-9 force-pushed the fix/1214-case-insensitive-repo-fullname branch from da0727a to ddd1052 Compare May 17, 2026 06:42
@igeabdulrahmanikeoluwa-str
Copy link
Copy Markdown

This lowercases the admin input but repo rows store GitHub's canonical casing — installation.handler.ts:44,52 insert repository.full_name unnormalized. For any repo whose canonical name has uppercase, lowercasing the input makes registerRepo's update({ repoFullName }) (admin.controller.ts:126) and getTokenForRepo's findOneBy({ repoFullName }) (github-fetcher.service.ts:198) miss the row — a regression on the previously-working exact-case path.

The repo already handles case-insensitive repo matching correctly in repos.service.ts:28 and pulls.service.ts:51 with LOWER(repo_full_name) = LOWER($1). Apply that same pattern to the registerRepo update and the getTokenForRepo lookup instead of normalizing input only — input-only normalization misses mixed-case repos since storage keeps canonical casing.

Good catch! You're right — input-only normalization misses repos stored with GitHub's canonical casing. Updated to use LOWER(repo_full_name) = LOWER(:repoFullName) in both registerRepo's update and getTokenForRepo's lookup, following the same pattern already used in repos.service.ts and pulls.service.ts

Already fixed now

@anderdc anderdc merged commit 1f9e3c3 into entrius:test May 17, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Admin repoFullName matching is case-sensitive, causing register/backfill failures for valid repos #91

3 participants