{"record":{"id":"b2eb08c0836c17ae","repo":"golang-migrate/migrate","slug":"no-access-token-b2eb08","errorCode":null,"errorMessage":"no access token","messagePattern":"no access token","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"source/gitlab/gitlab.go","lineNumber":25,"sourceCode":"\t\"net/http\"\n\tnurl \"net/url\"\n\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}","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/golang-migrate/migrate/blob/01a9643f1475e75bb6d6224ddeaf9d8e2434ca8a/source/gitlab/gitlab.go#L7-L43","documentation":"gitlab.ErrNoAccessToken is the GitLab driver's sentinel for a missing access token — the token (password part of the URL userinfo) required to call the GitLab API. Returned by Gitlab.Open when the token component is absent.","triggerScenarios":"Open('gitlab://user@gitlab.com/group/project') — username present but no ':token' — so no access token can be extracted; or empty password after templating ('user:@host').","commonSituations":"Rotated or revoked PATs removed from config; secret managers returning empty strings; docs examples copied without the token segment.","solutions":["Append the token to the userinfo: 'gitlab://user:<token>@gitlab.com/...'","Verify the secret/env value injecting the token is populated","Create a new PAT with api or read_api/read_repository scope if the old one was revoked"],"exampleFix":"// before\nsource.Open(\"gitlab://deploy@gitlab.com/group/project/migrations\")\n// after\nsource.Open(\"gitlab://deploy:glpat-xxx@gitlab.com/group/project/migrations\")","handlingStrategy":"validation","validationCode":"u, err := url.Parse(sourceURL)\nif err != nil {\n    return err\n}\nif u.Scheme == \"gitlab\" {\n    pw, ok := u.User.Password()\n    if !ok || pw == \"\" {\n        return fmt.Errorf(\"gitlab source url missing access token after ':' in userinfo\")\n    }\n}","typeGuard":"func hasGitlabToken(raw string) bool {\n    u, err := url.Parse(raw)\n    if err != nil || u.User == nil {\n        return false\n    }\n    pw, ok := u.User.Password()\n    return ok && pw != \"\"\n}","tryCatchPattern":"d, err := source_gitlab.Open(srcURL)\nif err != nil {\n    if errors.Is(err, source_gitlab.ErrNoAccessToken) {\n        return fmt.Errorf(\"add token as password part: gitlab://user:token@gitlab.com/...\")\n    }\n    return err\n}","preventionTips":["Never template tokens with values that may be empty; validate first","Verify PATs are active and unrevoked before deploys","Log URL scheme/path (never the token) when debugging auth failures"],"tags":["gitlab","authentication","token"],"backgroundTag":"missing-credentials","analyzedSha":"01a9643f1475e75bb6d6224ddeaf9d8e2434ca8a","analyzedAt":"2026-09-02T19:38:29.671Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}