{"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":"exception","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/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/integrations/gitlab/gitlab_client.py#L23-L59","documentation":"GitLabClient.__init__ requires both 'project' and 'access_token' keys in the config dict. This first check uses config.get(), so it raises only when a key is absent or explicitly None. project is the 'group/subgroup/repo' path or a numeric project id; access_token is a PAT or OAuth token that will be str()-coerced.","triggerScenarios":"Constructing GitLabClient (directly or via GitLabPromptManager / the initializers) with a dict missing 'project' or 'access_token'; keys spelled differently (projectId, token, accessToken); values explicitly None from os.getenv() without a default.","commonSituations":"Config assembled from environment variables where one variable is unset; config schema drift between environments; copy-pasting an example config with the token line removed; passing the GitLab URL instead of a project path.","solutions":["Include both keys: {'project': 'group/repo', 'access_token': '<token>'}","Load env vars with an explicit None check and fail fast when missing","Validate the config dict keys before constructing the client"],"exampleFix":"# before\nconfig = {\"project\": \"mygroup/myrepo\"}\nclient = GitLabClient(config)\n\n# after\nconfig = {\n    \"project\": \"mygroup/myrepo\",\n    \"access_token\": os.environ[\"GITLAB_TOKEN\"],\n}\nclient = GitLabClient(config)","handlingStrategy":"validation","validationCode":"REQUIRED_GITLAB_KEYS = (\"project\", \"access_token\")\n\n\ndef validate_gitlab_config(config: dict) -> None:\n    missing = [k for k in REQUIRED_GITLAB_KEYS if config.get(k) is None]\n    if missing:\n        raise ValueError(f\"gitlab config missing required keys: {missing}\")","typeGuard":"from typing import Any\n\n\ndef is_complete_gitlab_config(config: Any) -> bool:\n    \"\"\"True when both project and access_token keys are present (not None).\"\"\"\n    return (\n        isinstance(config, dict)\n        and config.get(\"project\") is not None\n        and config.get(\"access_token\") is not None\n    )","tryCatchPattern":"try:\n    client = GitLabClient(config)\nexcept ValueError as e:\n    if \"project and access_token are required\" in str(e):\n        raise RuntimeError(\n            \"gitlab_config needs non-None 'project' and 'access_token'\"\n        ) from e\n    raise","preventionTips":["Build config from typed settings where project/token are required fields","Fail fast at startup when GITLAB_TOKEN or the project slug is unset","Keep one shared config builder so key typos surface in a single place"],"tags":["gitlab","config","required-parameter","validation"],"backgroundTag":"missing-required-argument","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}