{"record":{"id":"4586c7713d0d8bae","repo":"golang-migrate/migrate","slug":"invalid-response","errorCode":null,"errorMessage":"invalid response","messagePattern":"invalid response","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"source/gitlab/gitlab.go","lineNumber":28,"sourceCode":"\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) {\n\tu, err := nurl.Parse(url)","sourceCodeStart":10,"sourceCodeEnd":46,"githubUrl":"https://github.com/golang-migrate/migrate/blob/01a9643f1475e75bb6d6224ddeaf9d8e2434ca8a/source/gitlab/gitlab.go#L10-L46","documentation":"ErrInvalidResponse is returned by the gitlab driver's readDirectory, ReadUp and ReadDown methods whenever the GitLab HTTP API responds with a status code other than 200 OK. It deliberately discards the underlying response status so callers see a single sentinel; the actual cause is almost always an authentication or permissions problem with the configured token.","triggerScenarios":"ListTree/GetFile calls against the GitLab API returning 401/403/404/500 — e.g. readDirectory during Open/WithInstance, or ReadUp/ReadDown fetching migration content with a non-200 response.","commonSituations":"Expired or revoked personal access token, token lacking 'api'/'read_repository' scope, wrong project id or branch name, private project the token cannot see, or GitLab downtime returning 5xx.","solutions":["Confirm the access token is valid and has 'api' and 'read_repository' scopes (test with curl -H \"PRIVATE-TOKEN: ...\" https://host/api/v4/projects)","Check the project path/id and ref (branch) in the gitlab:// URL point to an existing repository","Inspect GitLab server logs or retry manually to rule out a transient 5xx outage","If you need the real status code, wrap the driver or check GitLab API access independently, since the sentinel hides the HTTP status"],"exampleFix":"// before\ndb.Open(\"gitlab://user:expired-token@gitlab.example.com/group/project\")\n// after — regenerate token with api scope\ndb.Open(\"gitlab://oauth2:glpat-newtoken@gitlab.example.com/group/project?x-migrations-table=...\" )","handlingStrategy":"try-catch","validationCode":"req, _ := http.NewRequest(\"GET\", host+\"/api/v4/projects/\"+url.PathEscape(projectID), nil)\nreq.Header.Set(\"PRIVATE-TOKEN\", token)\nresp, err := http.DefaultClient.Do(req)\nif err != nil || resp.StatusCode != http.StatusOK {\n    return fmt.Errorf(\"gitlab API preflight failed: status=%d err=%v\", respStatus(resp), err)\n}","typeGuard":null,"tryCatchPattern":"src, err := gitlabDriver.WithInstance(...)\nif errors.Is(err, gitlab.ErrInvalidResponse) {\n    // token/permission/API problem; verify token manually and retry with backoff\n    return fmt.Errorf(\"gitlab rejected request (check token scope/permissions): %w\", err)\n}","preventionTips":["Check token validity and 'api'/'read_repository' scope before deploying","Test the exact project path and branch against the GitLab API with curl","Handle 5xx with retries; treat 401/403 as fatal config errors","Rotate tokens before expiry and store them in a secret manager"],"tags":["gitlab","http","api","auth"],"backgroundTag":"http-error-response","analyzedSha":"01a9643f1475e75bb6d6224ddeaf9d8e2434ca8a","analyzedAt":"2026-09-02T19:38:29.671Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}