fix: accept enterprise managed GitHub owner logins (#20450)

Unify owner validation across project pickers and repository overrides. Preserve EMU usernames in API and auth-status branch-prefix resolution, with regression coverage.

Co-authored-by: Neil <neil@stably.ai>
This commit is contained in:
Gon Song
2026-09-16 14:41:15 -07:00
committed by GitHub
co-authored by Neil
parent 6101f0169f
commit 85d1ffc072
16 changed files with 364 additions and 104 deletions
@@ -0,0 +1,25 @@
// Why: owner/repo overrides become authenticated REST paths, so the slug gate
// must keep rejecting path-shaped input while accepting every real login shape —
// including Enterprise Managed User logins, which end in `_<shortcode>`.
import { describe, expect, it } from 'vitest'
import { isValidGitHubApiRepository } from './github-api-repository-validation'
describe('isValidGitHubApiRepository', () => {
it('accepts plain and Enterprise Managed User owners', () => {
expect(isValidGitHubApiRepository({ owner: 'acme', repo: 'orca' })).toBe(true)
expect(isValidGitHubApiRepository({ owner: 'octocat_acme', repo: 'level5' })).toBe(true)
})
it('rejects leading underscore, hyphen, dot, and path-shaped owners', () => {
expect(isValidGitHubApiRepository({ owner: '_acme', repo: 'orca' })).toBe(false)
expect(isValidGitHubApiRepository({ owner: '-acme', repo: 'orca' })).toBe(false)
expect(isValidGitHubApiRepository({ owner: '.acme', repo: 'orca' })).toBe(false)
expect(isValidGitHubApiRepository({ owner: 'a/b', repo: 'orca' })).toBe(false)
})
it('rejects reserved and path-shaped repos', () => {
expect(isValidGitHubApiRepository({ owner: 'acme', repo: '.' })).toBe(false)
expect(isValidGitHubApiRepository({ owner: 'acme', repo: '..' })).toBe(false)
expect(isValidGitHubApiRepository({ owner: 'acme', repo: 'a/b' })).toBe(false)
})
})