Skip to content

fix(rss): detect empty or HTML responses that feedparser treats as non-bozo #36

Closed

Description

@2233admin

Problem

The W1 schema-drift wiring in #35 handles RSS parse failures when feedparser reports bozo=True. A different blind spot remains: HTTP 200 responses containing an HTML error page or an empty body can be parsed as bozo=False with entries=[].

Those responses currently look like a successful empty feed, so no structured error_type reaches the control recorder and the SCHEMA_DRIFT sensor does not fire.

Reproduction

Observed with feedparser using both:

  • an HTML error page body
  • an empty response body

In both cases the result can be bozo=False and entries=[].

Expected behavior

Classify suspicious empty/non-feed responses explicitly without treating legitimate empty feeds as schema drift.

Acceptance criteria

  • define a conservative distinction between a valid empty feed and a non-feed/empty HTTP response
  • return a structured error type for the suspicious cases
  • ensure that error type maps to the intended control error kind
  • add unit tests for HTML error pages, empty bodies, and a valid feed with zero entries
  • document any content-type or body-shape heuristics used

Scope note

Keep this separate from #35. That PR repairs error propagation for known parser failures; this issue covers response-quality detection before/around parser classification.

Activity

  1. added
    bugSomething is broken · 缺陷
    needs-triageMaintainer must evaluate · 待分诊
    on Jul 18, 2026
  2. 1012839419a-alt commented on Aug 7, 2026

    @1012839419a-alt
    Collaborator

    复核(2026-08-08):仍待修复

    对照 origin/main(7838811)检查:backend/channels/rss_channel.py 目前只有 _bozo_error_type()(处理 feedparser 标记 bozo 的情况,W1 相关,已修),没有针对空响应 / HTML 响应(feedparser 当作非 bozo 有效解析)的显式检测逻辑——grep 无 empty/text/html/non-bozo 相关分支。

    本 issue 描述的 bug 场景(空或 HTML 响应被当作有效 feed 解析出 0 条或垃圾条目)与 W1 是两回事,仍 open。修复方向:在 collect()/parse 后校验 entries 为空且 bozo 为 False 时,或 content-type 含 text/html 时,显式标记为失败(error_type 建议沿用 ParseError 以落入 SCHEMA_DRIFT 分类)。

  3. 1012839419a-alt commented on Aug 7, 2026

    @1012839419a-alt
    Collaborator

    修复完成(2026-08-08)

    已提交 PR #69(fix(rss): detect empty or HTML responses feedparser treats as non-bozo),关闭本 issue。

    核实结论

    origin/main 确实未修复:rss_channel.py 仅有 W1 的 _bozo_error_type()(bozo=True 分支),无空/HTML 响应的显式检测。

    复现(feedparser 6.0.12 实测)

    • 空 body → bozo=False, entries=0, version=None
    • HTML 错误页 / Cloudflare 页 → bozo=False, entries=0, version=''
    • 合法空 feed(rss20/atom10)→ bozo=False, entries=0, version='rss20'/'atom10'

    修复方案(保守区分)

    在 collect() 与 fetch() 的 bozo 分支之后增加检测:零条目且 feedparser 未识别任何 feed 格式(version 为空) → 显式失败,error_type="ParseError"(error_kinds.py 已映射 SCHEMA_DRIFT)。判据是 feedparser 的 version 字段(body-shape 启发式,已写入 docstring)。合法空 feed 因 version 非空不受影响;部分解析出条目的 feed 不受影响。

    验证

    • 新增 7 个单测:HTML 错误页 / 空 body / 非 feed 合法 XML → ParseError→SCHEMA_DRIFT;合法空 feed → 成功(collect + fetch 双路径)
    • pytest tests/unit/channels/ tests/unit/test_workflow_rss_source_executor.py:285 passed
    • ruff check:通过
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething is broken · 缺陷needs-triageMaintainer must evaluate · 待分诊

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions