fix: log fallback warning in blog posts endpoint and tighten test

This commit is contained in:
yuneng-jiang 2026-02-21 16:54:48 -08:00
parent 021a9097c4
commit 4b1ce1ff54
2 changed files with 6 additions and 1 deletions

View File

@ -4,6 +4,7 @@ from typing import List
from fastapi import APIRouter, Depends, HTTPException
from litellm._logging import verbose_logger
from litellm.litellm_core_utils.get_blog_posts import (
BlogPost,
BlogPostsResponse,
@ -213,7 +214,10 @@ async def get_litellm_blog_posts():
"""
try:
posts_data = get_blog_posts()
except Exception:
except Exception as e:
verbose_logger.warning(
"LiteLLM: get_litellm_blog_posts endpoint fallback triggered: %s", str(e)
)
posts_data = GetBlogPosts.load_local_blog_posts()
posts = [BlogPost(**p) for p in posts_data[:5]]

View File

@ -77,3 +77,4 @@ def test_get_blog_posts_returns_local_backup_on_failure(client):
# Should not 500 — returns local backup
assert response.status_code == 200
assert "posts" in response.json()
assert len(response.json()["posts"]) > 0