Reliable AI categories + image fallback for source-less articles#17
Conversation
Two issues surfaced on a published post (missing image, filed under the default 'Blog' instead of a topical category). Category: OpenAI used loose JSON mode, which does not guarantee required fields, so the model occasionally dropped 'category' and the post silently fell to WordPress's default category. - OpenAiProvider now uses strict Structured Outputs (json_schema, strict:true) so category and all required fields are always returned; falls back to JSON mode if the model rejects the schema. - PostFactory logs when a post keeps the site default category. Image: the source exposed no og:image and lazy-loaded its hero (real URL in data-src/srcset, src held an SVG placeholder), so extraction found nothing. - ContentExtractor reads data-src/data-lazy-src/data-original/srcset. - New optional default featured image (Settings + media picker) used only when an article has no image of its own. 92 tests pass.
|
Warning Review limit reached
Next review available in: 25 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (9)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Problem
A published post (Bangladesh anti-gambling law) surfaced two issues: no featured image, and filed under the default Blog category instead of a topical one. Both root-caused with evidence.
Category → "Blog" (intermittent)
The site categorizes most posts correctly, so this wasn't systemic.
OpenAiProviderused loose JSON mode (response_format: json_object), which only guarantees valid JSON, not that required fields are present. When the model occasionally droppedcategory,$structured['category'] ?? ''was empty and the post silently fell to WordPress's default category with no log.json_schema,strict: true) socategoryand all required fields are always returned. Schema is transformed to the strict-compatible subset (all props required,additionalProperties: false, unsupported length constraints stripped). Falls back to JSON mode if the model rejects the schema.PostFactorynow logs when a post keeps the site default category, closing the silent-fallback gap.Missing image (source gap + lazy-load blind spot)
The original source has no og:image/twitter:image and lazy-loads its hero: the raw
<img src>is an SVG placeholder, the real URL sits indata-src/srcset.first_content_imageonly readsrc, saw thedata:placeholder, and returned nothing.ContentExtractornow readsdata-src,data-lazy-src,data-original, and the firstsrcsetURL.Testing
92 tests pass (added lazy-load extraction cases and strict-schema transform cases), lint clean.