# \`fetch\_response\` 拒绝 HTTP 202 导致 IMDB 卡片失效

**URL:** <https://meta.discourse.org/t/fetch-response-rejects-http-202-breaking-imdb-oneboxes/407725>\
**Category:** Bug\
**Tags:** onebox, fixed\
**Created:** [2026年七月15日 19:38 UTC](https://meta.discourse.org/t/fetch-response-rejects-http-202-breaking-imdb-oneboxes/407725 "2026-07-15T19:38:44Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![dax](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dax/32/244677_2.png) [@dax](https://meta.discourse.org/u/dax)\
**Post date:** [2026年七月15日 19:38 UTC](https://meta.discourse.org/t/fetch-response-rejects-http-202-breaking-imdb-oneboxes/407725/1 "2026-07-15T19:38:44Z")

</div>

IMDB 目前返回 **HTTP 202 Accepted** 而非 **200 OK** （可能是由于反机器人措施或异步请求处理）。当前的实现过于严格，因为它仅将 200 视为成功响应，并将任何其他 2xx 状态视为错误。因此，响应体从未被读取，oneboxing 会失败并显示 _“error code of 202”_ 消息：

 ![image](https://global.discourse-cdn.com/meta/original/4X/b/d/f/bdf77e800ac22e93ca0bf2fe0ff9564fdd1c5314.png)

每当有人在帖子中粘贴 IMDB 链接时，这都会产生直接且用户可见的影响。

`fetch_response` 方法目前仅接受 **HTTP 200** 作为成功响应。任何其他 2xx 状态（包括 **202** ）都会被传递给 `response.error!`，导致在响应体被处理之前 fetch 失败。

> <https://github.com/discourse/discourse/blob/main/lib/onebox/helpers.rb#L116-L118>

我们是否可以接受完整的成功 HTTP 状态码范围（2xx），而不仅仅是 200？

---

_[View the full topic](https://meta.discourse.org/t/fetch-response-rejects-http-202-breaking-imdb-oneboxes/407725)._
