fix: normalize repoFullName to lowercase in validateRepoFullName#70
Conversation
anderdc
left a comment
There was a problem hiding this comment.
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
da0727a to
ddd1052
Compare
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 |
Summary
GitHub repository identity is case-insensitive, but admin endpoints
used exact-case matching. A request with
Entrius/das-github-mirrorwould fail to find a stored row of
entrius/das-github-mirror, causingvalid repos to get "Repo not found" errors on registration and breaking
downstream backfill flows in
getTokenForRepo.Root Cause
validateRepoFullNamereturned the input as-is without normalization.Both
registerRepoandbackfillRepocall it, so the raw casing floweddirectly into DB update and findOneBy queries.
Fix
One line —
.toLowerCase()on the return value ofvalidateRepoFullName.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