{"record":{"id":"f523ed88237996c7","repo":"Significant-Gravitas/AutoGPT","slug":"gcs-media-bucket-is-not-configured","errorCode":null,"errorMessage":"GCS media bucket is not configured","messagePattern":"GCS media bucket is not configured","errorType":"exception","errorClass":"MissingConfigError","httpStatus":503,"severity":"error","filePath":"autogpt_platform/backend/backend/api/features/store/media.py","lineNumber":35,"sourceCode":"ALLOWED_VIDEO_TYPES = {\"video/mp4\", \"video/webm\"}\nMAX_FILE_SIZE = 50 * 1024 * 1024  # 50MB\n\n\nasync def check_media_exists(user_id: str, filename: str) -> str | None:\n    \"\"\"\n    Check if a media file exists in storage for the given user.\n    Tries both images and videos directories.\n\n    Args:\n        user_id (str): ID of the user who uploaded the file\n        filename (str): Name of the file to check\n\n    Returns:\n        str | None: URL of the blob if it exists, None otherwise\n    \"\"\"\n    settings = Settings()\n    if not settings.config.media_gcs_bucket_name:\n        raise MissingConfigError(\"GCS media bucket is not configured\")\n\n    async with async_storage.Storage() as async_client:\n        bucket_name = settings.config.media_gcs_bucket_name\n\n        # Check images\n        image_path = f\"users/{user_id}/images/{filename}\"\n        try:\n            await async_client.download_metadata(bucket_name, image_path)\n            # If we get here, the file exists - construct public URL\n            return f\"https://storage.googleapis.com/{bucket_name}/{image_path}\"\n        except Exception:\n            # File doesn't exist, continue to check videos\n            pass\n\n        # Check videos\n        video_path = f\"users/{user_id}/videos/{filename}\"\n        try:\n            await async_client.download_metadata(bucket_name, video_path)","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/Significant-Gravitas/AutoGPT/blob/9c8bb5550f446ba5d3046b78896578742495b3cf/autogpt_platform/backend/backend/api/features/store/media.py#L17-L53","documentation":"MissingConfigError raised by store_media.check_media_exists() (and the same guard pattern in the rest of media.py) when Settings().config.media_gcs_bucket_name is empty. All media lookups/uploads construct GCS paths from this bucket name, so the module refuses to operate rather than silently reading/writing a bogus bucket.","triggerScenarios":"Any store media endpoint (check media existence, upload agent image, serve media) on a deployment where MEDIA_GCS_BUCKET_NAME is not set — fresh local dev, new staging environment, or the GCS media feature not provisioned.","commonSituations":".env copied from .env.default which leaves the bucket blank for local runs; production secret not migrated during infra move; bucket renamed without updating config.","solutions":["Set MEDIA_GCS_BUCKET_NAME (per backend/.env.default naming) to an existing GCS bucket and restart the backend.","Ensure the bucket exists and the service account/credentials the backend uses has read (and write, for uploads) access to it.","For environments that intentionally skip media, avoid calling media endpoints or feature-flag the UI paths that hit them."],"exampleFix":"// before\n# backend/.env\n# MEDIA_GCS_BUCKET_NAME=\n\n// after\nMEDIA_GCS_BUCKET_NAME=agpt-media-prod","handlingStrategy":"validation","validationCode":"from backend.util.settings import Settings\n\ndef media_configured() -> bool:\n    return bool(Settings().config.media_gcs_bucket_name)","typeGuard":null,"tryCatchPattern":"from backend.util.exceptions import MissingConfigError\n\ntry:\n    url = await store_media.check_media_exists(user_id, filename)\nexcept MissingConfigError:\n    raise HTTPException(503, \"Media storage is not configured\")","preventionTips":["Include MEDIA_GCS_BUCKET_NAME in environment provisioning templates.","Fail fast at startup with a warning when media endpoints are exposed without a bucket."],"tags":["store","config","gcs","media","backend"],"backgroundTag":null,"analyzedSha":"9c8bb5550f446ba5d3046b78896578742495b3cf","analyzedAt":"2026-08-14T17:17:21.957Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}