BerriAI/litellm · error · ValueError

Unsupported frequency

Error message

Unsupported frequency: {self.frequency}

What it means

FocusLogger raises ValueError('Unsupported frequency') in its scheduler-config method when self.frequency is not one of 'interval', 'hourly', or 'daily'. Frequency defaults to 'hourly' and is normally set via the constructor or the FOCUS_FREQUENCY env var (it is lowercased on assignment). This code path builds the APScheduler trigger for the automatic export runs.

Solutions

  1. Use one of the supported values: 'hourly', 'daily', or 'interval' (interval also needs interval_seconds).
  2. Check FOCUS_FREQUENCY in the deployment environment and fix the value.
  3. For custom schedules, run an external cron that calls export_usage_data(start_time_utc=..., end_time_utc=...) instead.
  4. Validate the value at startup and fail fast with your own error message.

Example fix

# before
export FOCUS_FREQUENCY=weekly

# after
export FOCUS_FREQUENCY=daily
Defensive patterns

Strategy: type-guard

Validate before calling

freq = (os.getenv('FOCUS_FREQUENCY') or 'hourly').strip().lower()
if freq not in {'interval', 'hourly', 'daily'}:
    raise SystemExit(f'FOCUS_FREQUENCY must be interval|hourly|daily, got {freq!r}')

Type guard

def is_valid_focus_frequency(freq: str | None) -> bool:
    return (freq or '').strip().lower() in {'interval', 'hourly', 'daily'}

Prevention

When it happens

Trigger: Setting FOCUS_FREQUENCY=weekly, monthly, or 'Hourly ' (whitespace) in the environment; passing frequency='minutes' to the FocusLogger constructor; a value that lowercases to something outside the three supported strings.

Common situations: Wanting weekly/monthly FOCUS exports, which are not implemented; typo in the env var value; assuming cron-style expressions are accepted as frequency.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


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

Appendix: source

Thrown at litellm/integrations/focus/focus_logger.py:172

        )

    def _build_scheduler_trigger(self) -> dict[str, Any]:
        """Return scheduler configuration for the selected frequency."""
        if self.frequency == "interval":
            seconds: Final = self.interval_seconds or 60
            return {"trigger": "interval", "seconds": seconds}

        if self.frequency == "hourly":
            minute = max(0, min(59, self.cron_offset_minute))
            return {"trigger": "cron", "minute": minute, "second": 0}

        if self.frequency == "daily":
            total_minutes: Final = max(0, self.cron_offset_minute)
            hour: Final = min(23, total_minutes // 60)
            minute = min(59, total_minutes % 60)
            return {"trigger": "cron", "hour": hour, "minute": minute, "second": 0}

        raise ValueError(f"Unsupported frequency: {self.frequency}")

    async def _run_scheduled_export(self) -> None:
        """Execute the scheduled export for the configured window."""
        window: Final = self._compute_time_window(datetime.now(timezone.utc))
        await self._export_window(window=window, limit=None)

    async def _export_all(
        self,
        *,
        limit: int | None,
    ) -> None:
        """Export all available data without a time window filter."""
        engine: Final = self._ensure_engine()
        await engine.export_all(limit=limit)

    async def _export_window(
        self,
        *,

View on GitHub (pinned to 77b7c6c40c)