{"record":{"id":"a2a9f4e7078afc21","repo":"golang-migrate/migrate","slug":"invalid-project-id","errorCode":null,"errorMessage":"invalid project id","messagePattern":"invalid project id","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"source/gitlab/gitlab.go","lineNumber":27,"sourceCode":"\t\"os\"\n\t\"strconv\"\n\t\"strings\"\n\n\t\"github.com/golang-migrate/migrate/v4/source\"\n\t\"github.com/xanzy/go-gitlab\"\n)\n\nfunc init() {\n\tsource.Register(\"gitlab\", &Gitlab{})\n}\n\nconst DefaultMaxItemsPerPage = 100\n\nvar (\n\tErrNoUserInfo       = fmt.Errorf(\"no username:token provided\")\n\tErrNoAccessToken    = fmt.Errorf(\"no access token\")\n\tErrInvalidHost      = fmt.Errorf(\"invalid host\")\n\tErrInvalidProjectID = fmt.Errorf(\"invalid project id\")\n\tErrInvalidResponse  = fmt.Errorf(\"invalid response\")\n)\n\ntype Gitlab struct {\n\tclient *gitlab.Client\n\turl    string\n\n\tprojectID   string\n\tpath        string\n\tlistOptions *gitlab.ListTreeOptions\n\tgetOptions  *gitlab.GetFileOptions\n\tmigrations  *source.Migrations\n}\n\ntype Config struct {\n}\n\nfunc (g *Gitlab) Open(url string) (source.Driver, error) {","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/golang-migrate/migrate/blob/01a9643f1475e75bb6d6224ddeaf9d8e2434ca8a/source/gitlab/gitlab.go#L9-L45","documentation":"ErrInvalidProjectID is returned by gitlab.Open when the URL path does not contain a project id. Open strips the URL path and splits on '/'; if the resulting segments list is empty (no project path in the URL), it cannot determine which repository holds the migrations and returns this sentinel error.","triggerScenarios":"Opening a gitlab:// driver whose URL path is empty or only slashes, e.g. gitlab://user:token@host/ — strings.Split of the trimmed path yields fewer than 1 element.","commonSituations":"Connection string copy/paste errors where the group/project suffix was dropped; building the URL programmatically with an unset project variable; trailing-slash-only URLs.","solutions":["Append the project path to the URL: gitlab://user:token@host/group/project","Check that any variable interpolated into the connection string is non-empty at runtime","Trim stray trailing slashes and confirm the path segment after the host is present"],"exampleFix":"// before\ndb.Open(\"gitlab://oauth2:token@gitlab.example.com/\")\n// after\ndb.Open(\"gitlab://oauth2:token@gitlab.example.com/mygroup/myproject\")","handlingStrategy":"validation","validationCode":"u, err := url.Parse(gitlabURL)\nif err != nil {\n    return err\n}\nif strings.Trim(u.Path, \"/\") == \"\" {\n    return fmt.Errorf(\"gitlab URL must include group/project path\")\n}","typeGuard":null,"tryCatchPattern":"d, err := gitlabDriver.Open(gitlabURL)\nif errors.Is(err, gitlab.ErrInvalidProjectID) {\n    log.Fatalf(\"missing project path in %s\", gitlabURL)\n}","preventionTips":["Keep the connection string in one constant/config value and review it","Validate the URL shape in unit tests for config loading","Avoid building the URL by naive string concatenation of possibly-empty parts"],"tags":["gitlab","config","url","migration"],"backgroundTag":"missing-config-value","analyzedSha":"01a9643f1475e75bb6d6224ddeaf9d8e2434ca8a","analyzedAt":"2026-09-02T19:38:29.671Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}