{"record":{"id":"d359d491eaa18121","repo":"BerriAI/litellm","slug":"workspace-repository-and-access-token-are-requir","errorCode":null,"errorMessage":"workspace, repository, and access_token are required","messagePattern":"workspace, repository, and access_token are required","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/integrations/bitbucket/bitbucket_client.py","lineNumber":57,"sourceCode":"            config: Dictionary containing:\n                - workspace: BitBucket workspace name\n                - repository: Repository name\n                - access_token: BitBucket access token (or app password)\n                - branch: Branch to fetch from (default: main)\n                - base_url: Custom BitBucket API base URL (optional)\n                - auth_method: Authentication method ('token' or 'basic', default: 'token')\n                - username: Username for basic auth (optional)\n        \"\"\"\n        self.workspace = config.get(\"workspace\")\n        self.repository = config.get(\"repository\")\n        self.access_token = config.get(\"access_token\")\n        self.branch = config.get(\"branch\", \"main\")\n        self.base_url = config.get(\"\", \"https://api.bitbucket.org/2.0\")\n        self.auth_method = config.get(\"auth_method\", \"token\")\n        self.username = config.get(\"username\")\n\n        if not all([self.workspace, self.repository, self.access_token]):\n            raise ValueError(\"workspace, repository, and access_token are required\")\n\n        # Set up authentication headers\n        self.headers = {\n            \"Accept\": \"application/json\",\n            \"Content-Type\": \"application/json\",\n        }\n\n        if self.auth_method == \"basic\" and self.username:\n            # Use basic auth with username and app password\n            credentials: Final = f\"{self.username}:{self.access_token}\"\n            encoded_credentials: Final = base64.b64encode(credentials.encode()).decode()\n            self.headers[\"Authorization\"] = f\"Basic {encoded_credentials}\"\n        else:\n            # Use token-based authentication (default)\n            self.headers[\"Authorization\"] = f\"Bearer {self.access_token}\"\n\n        # Initialize HTTPHandler\n        self.http_handler = HTTPHandler()","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/integrations/bitbucket/bitbucket_client.py#L39-L75","documentation":"BitBucketClient.__init__ requires three non-empty keys in the config dict: workspace, repository, and access_token. It reads them with .get() and uses all([...]) — a missing, None, or empty-string value for any one triggers this ValueError. branch, auth_method, username and base_url are optional (with defaults), and note the base_url default line reads config.get(\"\", ...) so an empty key is effectively ignored — only the three required keys are enforced.","triggerScenarios":"Constructing BitBucketClient (or BitBucketPromptManager) with a config dict missing any of workspace/repository/access_token; token present but workspace empty string; auth_method 'basic' with username and app password where the password was put in username's place leaving access_token empty.","commonSituations":"Config assembled from env vars where one is unset (empty string); copy from docs then replacing only two of three placeholders; storing the app password in a vault and forgetting to inject it into the config.","solutions":["Ensure all three keys are present and non-empty: workspace, repository, access_token","If values come from env vars, fail fast at startup when any is missing","For basic auth (app password), access_token holds the app password and username must also be set","Verify the token is a BitBucket app password / repository token with read access to the repo"],"exampleFix":"# before\nconfig = {\"workspace\": \"my-workspace\", \"repository\": \"my-repo\"}  # no token -> ValueError\n\n# after\nconfig = {\n    \"workspace\": \"my-workspace\",\n    \"repository\": \"my-repo\",\n    \"access_token\": os.environ[\"BITBUCKET_APP_PASSWORD\"],\n    \"auth_method\": \"basic\",\n    \"username\": \"my-user\",\n}","handlingStrategy":"validation","validationCode":"def make_bitbucket_config(env: dict) -> dict:\n    cfg = {\n        \"workspace\": env.get(\"BITBUCKET_WORKSPACE\", \"\"),\n        \"repository\": env.get(\"BITBUCKET_REPOSITORY\", \"\"),\n        \"access_token\": env.get(\"BITBUCKET_ACCESS_TOKEN\", \"\"),\n    }\n    missing = [k for k, v in cfg.items() if not v]\n    if missing:\n        raise RuntimeError(f\"BitBucket config incomplete: missing {missing}\")\n    return cfg","typeGuard":"def is_complete_bitbucket_config(cfg) -> bool:\n    return (\n        isinstance(cfg, dict)\n        and all(isinstance(cfg.get(k), str) and cfg[k].strip() for k in (\"workspace\", \"repository\", \"access_token\"))\n    )","tryCatchPattern":"try:\n    client = BitBucketClient(config)\nexcept ValueError as e:\n    if \"workspace, repository, and access_token are required\" in str(e):\n        raise ConfigError(f\"BitBucket config incomplete: {sorted(config.keys())}\") from e\n    raise","preventionTips":["Fail fast on unset env vars with a named list of what is missing","Strip whitespace on tokens loaded from env/vault","For basic auth remember username is also required even though only three keys are checked","Validate the config dict shape in a unit test for your config loader"],"tags":["bitbucket","configuration","authentication","validation"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}