Skip to content

[故障报告] #1790

Description

@HotDogEggBurger

Bug Report: crawler (anydoc) panic when parsing Redoc-generated HTML files

描述

当上传包含外部 CDN 脚本引用的 Redoc 生成的 API 文档 HTML 文件时,panda-wiki-crawler(anydoc)在处理该文件时发生 nil pointer dereference panic,导致接口返回 500,文件始终无法被成功解析入库。

环境信息

  • anydoc 版本:v0.9.11
  • panda-wiki-api 版本:v3.84.1
  • 部署方式:Docker Compose

复现步骤

  1. 准备一个由 Redoc 生成的 API 文档 HTML 文件,文件头部包含如下外部脚本引用:
    <script src="https://cdn.redoc.ly/redoc/v2.0.0/bundles/redoc.standalone.js"></script>
  2. 通过 PandaWiki 界面上传该 HTML 文件
  3. 观察 crawler 日志,可看到 panic 输出

实际表现

crawler 返回 HTTP 500,响应体为空。panda-wiki-api 侧报错:

level=ERROR msg="scrape url failed" error="unexpected end of JSON input"

crawler 容器日志中出现以下 panic:

2026/04/20 18:24:51 [Recovery] panic recovered:
runtime error: invalid memory address or nil pointer dereference
/app/pkg/third_doc/url.go:184
[/app/svc/doc/url.go:36](url)

[扩展元数据.html](https://github.com/user-attachments/files/26916964/default.html)

/app/handler/doc/url.go:37

预期表现

crawler 应能正常解析该 HTML 文件内容并返回结构化数据,或在无法解析时返回明确的错误信息,而不是发生 panic。

补充信息

  • 该 HTML 文件可通过 MinIO 正常访问,内容完整,非空文件
  • 外部 CDN 地址(cdn.redoc.ly)在服务器上可正常访问(HTTP 200)
  • 崩溃位置固定在 /app/pkg/third_doc/url.go:184,推测是解析页面某个字段时未做 nil 判断
  • 对应的附件是我提供的demo附件,传上去就报错

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions