{"record":{"id":"a64defb24dd0c885","repo":"BerriAI/litellm","slug":"project-and-access-token-are-required","errorCode":null,"errorMessage":"project and access_token are required","messagePattern":"project and access_token are required","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/integrations/gitlab/gitlab_client.py","lineNumber":41,"sourceCode":"    \"\"\"\n\n    def __init__(self, config: dict[str, Any]):\n        \"\"\"\n        Initialize the GitLab client.\n\n        Args:\n            config: Dictionary containing:\n                - project: Project path (\"group/subgroup/repo\") or numeric project ID (str|int) [required]\n                - access_token: GitLab personal/access token or OAuth token [required] (str)\n                - auth_method: 'token' (default; sends Private-Token) or 'oauth' (Authorization: Bearer)\n                - tag: Tag name to fetch from (takes precedence over branch if provided)\n                - branch: Branch to fetch from (default: \"main\")\n                - base_url: Base GitLab API URL (default: \"https://gitlab.com/api/v4\")\n        \"\"\"\n        project: Final = config.get(\"project\")\n        access_token: Final = config.get(\"access_token\")\n        if project is None or access_token is None:\n            raise ValueError(\"project and access_token are required\")\n\n        self.project: str | int = project\n        self.access_token: str = str(access_token)\n        self.auth_method = config.get(\"auth_method\", \"token\")  # 'token' or 'oauth'\n        self.branch = config.get(\"branch\", None)\n        if not self.branch:\n            self.branch = \"main\"\n        self.tag = config.get(\"tag\")\n        self.base_url = config.get(\"base_url\", \"https://gitlab.com/api/v4\")\n\n        if not all([self.project, self.access_token]):\n            raise ValueError(\"project and access_token are required\")\n\n        # Effective ref: prefer tag if provided, else branch (\"main\")\n        self.ref = str(self.tag or self.branch)\n\n        # Build headers\n        self.headers = {","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/integrations/gitlab/gitlab_client.py#L23-L59","documentation":"First of two guards in GitLabClient.__init__: raised when config.get('project') or config.get('access_token') returns None, i.e. the keys are entirely absent from gitlab_config. The second guard (line 53) catches falsy-but-present values like empty strings, so this one specifically means the keys are missing.","triggerScenarios":"Constructing GitLabClient (or the GitLab prompt integration) with a gitlab_config dict that lacks 'project' or 'access_token'; keys present but named differently ('repo', 'token', 'private_token') so .get returns None.","commonSituations":"Translating git CLI URLs into config by hand and using 'repo' instead of 'project'; config templating that strips secret keys when the token env var is undefined; onboarding from GitLab CI docs where the variable is named CI_JOB_TOKEN.","solutions":["Include both keys in gitlab_config: project (e.g. 'group/subgroup/repo' or numeric ID) and access_token.","Use the exact key names — 'project' and 'access_token'; rename 'repo'/'token'/'pat' accordingly.","If loading from environment, ensure the token variable is set before config construction, not lazily."],"exampleFix":"# before\ngitlab_config = {\"repo\": \"acme/api\", \"token\": \"glpat-...\"}\n\n# after\ngitlab_config = {\"project\": \"acme/api\", \"access_token\": \"glpat-...\"}","handlingStrategy":"validation","validationCode":"def build_gitlab_config(project: str | None, access_token: str | None) -> dict:\n    if project is None or access_token is None:\n        raise ValueError(\"gitlab_config requires both 'project' and 'access_token' keys\")\n    return {\"project\": project, \"access_token\": access_token}","typeGuard":"def has_project_and_token_keys(cfg: dict) -> bool:\n    return isinstance(cfg, dict) and \"project\" in cfg and \"access_token\" in cfg","tryCatchPattern":null,"preventionTips":["Use the canonical key names 'project' and 'access_token' everywhere, including IaC templates.","Add schema validation (e.g. pydantic) over gitlab_config at config load."],"tags":["gitlab","config","validation","missing-argument"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}