BerriAI/litellm · error · ValueError

gitlab_config is required for gitlab prompt integration

Error message

gitlab_config is required for gitlab prompt integration

What it means

The legacy GitLab prompt initializer (prompt_initializer in litellm/integrations/gitlab/__init__.py) found no gitlab_config on the prompt's litellm_params. The GitLab prompt integration stores all connection details (project, access_token, branch, prompts_path) in that dict, so an absent, None or empty (falsy) dict aborts initialization before any GitLab request is made.

Solutions

  1. Add a non-empty gitlab_config dict under litellm_params with at least project and access_token
  2. Check key spelling and nesting: it must be litellm_params.gitlab_config.project / .access_token
  3. If config is env-driven, build the dict first and fail fast when it would be empty
  4. Alternatively set a global config via litellm.integrations.gitlab.set_global_gitlab_config

Example fix

# before
prompt_spec = {
    "prompt_id": "chat/greet",
    "litellm_params": {"prompt_integration": "gitlab"},
}

# after
prompt_spec = {
    "prompt_id": "chat/greet",
    "litellm_params": {
        "prompt_integration": "gitlab",
        "gitlab_config": {
            "project": "mygroup/myrepo",
            "access_token": os.environ["GITLAB_TOKEN"],
            "branch": "main",
        },
    },
}
Defensive patterns

Strategy: validation

Validate before calling

def validate_gitlab_prompt_spec(prompt_spec: dict) -> None:
    cfg = (prompt_spec.get("litellm_params") or {}).get("gitlab_config")
    if not cfg:
        raise ValueError(
            "prompt '%s' uses the gitlab integration but has no non-empty "
            "litellm_params.gitlab_config" % prompt_spec.get("prompt_id")
        )
    missing = [k for k in ("project", "access_token") if cfg.get(k) is None]
    if missing:
        raise ValueError(f"gitlab_config missing keys: {missing}")

Type guard

from typing import Any


def has_gitlab_config(litellm_params: Any) -> bool:
    """True when litellm_params carries a non-empty gitlab_config."""
    return bool(getattr(litellm_params, "gitlab_config", None))

Try / catch

try:
    manager = prompt_initializer(litellm_params, prompt_spec)
except ValueError as e:
    if "gitlab_config is required" in str(e):
        raise RuntimeError(
            "GitLab prompt declared without gitlab_config - fix the prompt spec"
        ) from e
    raise

Prevention

When it happens

Trigger: Declaring a prompt with prompt_integration='gitlab' but omitting litellm_params.gitlab_config; passing gitlab_config={} (the truthiness check rejects empty dicts too); misspelling the key (gitlabConfig, gitlab_cfg); nesting the dict at the top level of the prompt spec instead of under litellm_params.

Common situations: config.yaml prompt definitions missing the gitlab_config block; token-assembly code producing an empty dict when env vars are unset; copy-pasting a prompt spec from another integration without adapting the config key; version drift in where the initializer looks for the attribute.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/def9c67151358ee0. Report an issue: GitHub.

Appendix: source

Thrown at litellm/integrations/gitlab/__init__.py:42

                - workspace: gitlab workspace name
                - repository: Repository name
                - access_token: gitlab access token
                - branch: Branch to fetch prompts from (default: main)
    """
    import litellm

    litellm.global_gitlab_config = config


def prompt_initializer(litellm_params: "PromptLiteLLMParams", prompt_spec: "PromptSpec") -> "CustomPromptManagement":
    """
    Initialize a prompt from a Gitlab repository.
    """
    gitlab_config: Final = getattr(litellm_params, "gitlab_config", None)
    prompt_id: Final = getattr(litellm_params, "prompt_id", None)

    if not gitlab_config:
        raise ValueError("gitlab_config is required for gitlab prompt integration")

    try:
        gitlab_prompt_manager: Final = GitLabPromptManager(
            gitlab_config=gitlab_config,
            prompt_id=prompt_id,
        )

        return gitlab_prompt_manager
    except Exception as e:
        raise e


def _gitlab_prompt_initializer(
    litellm_params: PromptLiteLLMParams,
    prompt: PromptSpec,
) -> CustomPromptManagement:
    """
    Build a GitLab-backed prompt manager for this prompt.

View on GitHub (pinned to 77b7c6c40c)