block/buzz · critical · anyhow::Error

invalid media config: {e}

Error message

invalid media config: {e}

What it means

config.media.validate() checks the media (Blossom/S3) configuration before any storage client is built. Missing required fields for the selected backend — e.g. S3 without bucket, region, or endpoint — surface here with the validation message appended, aborting startup.

Source

Thrown at crates/buzz-relay/src/main.rs:451

            "0000000000000000000000000000000000000000000000000000000000000001";
        let keys = nostr::Keys::parse(DEV_RELAY_PRIVKEY).expect("hardcoded dev key is valid");
        tracing::warn!(
            pubkey = %keys.public_key().to_hex(),
            "Using hardcoded dev relay keypair (BUZZ_REQUIRE_AUTH_TOKEN=false). \
             Set BUZZ_RELAY_PRIVATE_KEY for production."
        );
        keys
    } else {
        panic!(
            "BUZZ_RELAY_PRIVATE_KEY must be set when BUZZ_REQUIRE_AUTH_TOKEN=true. \
             A stable relay identity is required for production."
        );
    };

    config
        .media
        .validate()
        .map_err(|e| anyhow::anyhow!("invalid media config: {e}"))?;
    let media_storage = buzz_media::MediaStorage::new(&config.media)
        .map_err(|e| anyhow::anyhow!("failed to initialize media storage: {e}"))?;
    info!("Media storage connected");

    let (app_state, audit_shutdown) = AppState::new(
        config.clone(),
        db,
        redis_health_pool,
        audit,
        pubsub,
        auth,
        search,
        Arc::clone(&workflow_engine),
        relay_keypair,
        media_storage,
    );
    let state = Arc::new(app_state);

View on GitHub (pinned to f956e6fe06)

Solutions

  1. Read {e} — it names the missing or invalid media field
  2. Complete the media section of .env per .env.example for the chosen backend
  3. If media is not needed, revert the media config to the disabled/local default

Example fix

# before
BUZZ_MEDIA_BACKEND=s3
# BUZZ_MEDIA_S3_BUCKET unset

# after
BUZZ_MEDIA_BACKEND=s3
BUZZ_MEDIA_S3_BUCKET=buzz-media
BUZZ_MEDIA_S3_REGION=us-east-1
Defensive patterns

Strategy: validation

Validate before calling

# Every media var referenced by the active backend must be set.
if [ "${BUZZ_MEDIA_BACKEND:-}" = "s3" ]; then
  for v in BUZZ_MEDIA_S3_BUCKET BUZZ_MEDIA_S3_REGION; do
    [ -n "${!v:-}" ] || { echo "missing $v"; exit 1; }
  done
fi

Prevention

When it happens

Trigger: Selecting an S3-backed media backend without providing all required S3 env vars; combining incompatible media storage options.

Common situations: Enabling media uploads in a new environment with only a partial env set; media env var renames between releases; copying .env from a local-disk setup into an S3 deployment.

Related errors


AI-assisted analysis of block/buzz@f956e6fe06 (2026-08-16). Data as JSON: /api/errors/862c86efb6a85b2f. Report an issue: GitHub.