{"record":{"id":"83374242249eb762","repo":"golang-migrate/migrate","slug":"invalid-repo-833742","errorCode":null,"errorMessage":"invalid repo","messagePattern":"invalid repo","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"source/github/github.go","lineNumber":26,"sourceCode":"\tnurl \"net/url\"\n\t\"os\"\n\t\"path\"\n\t\"strings\"\n\n\t\"golang.org/x/oauth2\"\n\n\t\"github.com/golang-migrate/migrate/v4/source\"\n\t\"github.com/google/go-github/v39/github\"\n)\n\nfunc init() {\n\tsource.Register(\"github\", &Github{})\n}\n\nvar (\n\tErrNoUserInfo          = fmt.Errorf(\"no username:token provided\")\n\tErrNoAccessToken       = fmt.Errorf(\"no access token\")\n\tErrInvalidRepo         = fmt.Errorf(\"invalid repo\")\n\tErrInvalidGithubClient = fmt.Errorf(\"expected *github.Client\")\n\tErrNoDir               = fmt.Errorf(\"no directory\")\n)\n\ntype Github struct {\n\tconfig     *Config\n\tclient     *github.Client\n\toptions    *github.RepositoryContentGetOptions\n\tmigrations *source.Migrations\n}\n\ntype Config struct {\n\tOwner string\n\tRepo  string\n\tPath  string\n\tRef   string\n}\n","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/golang-migrate/migrate/blob/01a9643f1475e75bb6d6224ddeaf9d8e2434ca8a/source/github/github.go#L8-L44","documentation":"github.ErrInvalidRepo is returned by Github.Open when the URL path yields no repo segment after trimming slashes (len(pe) < 1). The driver expects 'github://host/owner/repo/...path' and needs at least one path element to use as the repo.","triggerScenarios":"Open('github://token@github.com/') or 'github://token@github.com' — empty path — so strings.Split of the trimmed path returns fewer than 1 element.","commonSituations":"URL templates where owner/repo placeholders were not filled; trailing-slash-only paths; copying only the host from a repo URL and dropping the path.","solutions":["Include owner and repo in the URL path: 'github://user:token@github.com/owner/repo/path/to/migrations'","Note the driver maps path element 0 to Repo (Owner comes from u.Host) — structure the URL accordingly","Validate the URL contains a non-empty path before calling Open"],"exampleFix":"// before\nsource.Open(\"github://user:token@github.com/\")\n// after\nsource.Open(\"github://user:token@github.com/owner/repo/migrations\")","handlingStrategy":"validation","validationCode":"u, err := url.Parse(sourceURL)\nif err != nil {\n    return err\n}\npe := strings.Split(strings.Trim(u.Path, \"/\"), \"/\")\nif len(pe) < 1 || pe[0] == \"\" {\n    return fmt.Errorf(\"github source url must include a repo path: github://token@github.com/owner/repo\")\n}","typeGuard":"func hasRepoInPath(raw string) bool {\n    u, err := url.Parse(raw)\n    return err == nil && strings.Trim(u.Path, \"/\") != \"\"\n}","tryCatchPattern":"d, err := source.Open(srcURL)\nif err != nil {\n    if errors.Is(err, source_github.ErrInvalidRepo) {\n        return fmt.Errorf(\"source url %q missing repo path segment\", srcURL)\n    }\n    return err\n}","preventionTips":["Template the full host/owner/repo/path URL and validate placeholders were filled","Remember owner comes from host, repo from first path segment in this driver","Test URL construction with a unit test before deployment"],"tags":["github","url","configuration"],"backgroundTag":"invalid-repository-url","analyzedSha":"01a9643f1475e75bb6d6224ddeaf9d8e2434ca8a","analyzedAt":"2026-09-02T19:38:29.671Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}