/search/query 响应体因未知原因而更改

你好!

我们在网站中开发了一个功能,用于查询托管的 Discourse 论坛并显示找到的主题信息。上周部署时一切正常,但本周末却出问题了。原来,查询返回的 topic 对象结构发生了很大变化。

根据开发期间的测试,以及最新的文档,预期的响应对象如下:latest docs

"topics": [
        {
            "id": 1099,
            "title": "Build Error: ipykernel 4.8.2 for python 3.6.6 on Windows",
            "fancy_title": "Build Error: ipykernel 4.8.2 for python 3.6.6 on Windows",
            "slug": "build-error-ipykernel-4-8-2-for-python-3-6-6-on-windows",
            "posts_count": 1,
            "reply_count": 0,
            "highest_post_number": 1,
            "image_url": null,
            "created_at": "2020-06-30T23:36:42.277Z",
            "last_posted_at": "2020-06-30T23:36:42.357Z",
            "bumped": true,
            "bumped_at": "2020-06-30T23:36:42.357Z",
            "archetype": "regular",
            "unseen": false,
            "pinned": false,
            "unpinned": null,
            "visible": true,
            "closed": false,
            "archived": false,
            "bookmarked": null,
            "liked": null,
            "thumbnails": null,
            "tags": [
                "windows",
                "builder"
            ],
            "category_id": 1,
            "has_accepted_answer": false
        }
    ],

实际/当前的响应:

 "topics": [
        {
            "id": 1494,
            "fancy_title": "Build Error: python-magic 0.4.15 for Python 3.8.2 on Mac",
            "slug": "build-error-python-magic-0-4-15-for-python-3-8-2-on-mac",
            "posts_count": 1,
            "archetype": "regular",
            "pinned": false,
            "unpinned": null,
            "visible": true,
            "closed": false,
            "archived": false,
            "bookmarked": null,
            "liked": null,
            "tags": [
                "mac",
                "builder"
            ],
            "category_id": 1,
            "has_accepted_answer": false
        }
    ],

我在想,是否是因为发布了某个更新,导致搜索 API 的响应发生了变化?或者更有可能的是,是否有管理员设置会导致这种情况?

我查看了最近一次更新(2.5 版本于 6 月 24 日发布)的变更日志,但没有发现任何明确提及 API 变更的内容。

提前感谢任何帮助。

  • Carey

是的,最近从搜索请求返回的响应数据中移除了以下主题属性:

    image_url
    thumbnails
    title
    created_at
    last_posted_at
    bumped_at
    bumped
    highest_post_number
    reply_count
    unseen

此次更改是出于性能考虑。您仍可通过 fancy_title 属性获取标题。我们将更新文档以反映此变更。

非常感谢 @simon

感谢你的澄清。幸好我们已经在用 fancy_title 了,问题出在 created_at 上。

哦,那一定是发布说明里的这一条:提升分类主题列表的性能

有没有什么地方可以让我关注即将发生的 API 变更?

再次感谢你的快速帮助。

  • Carey

抱歉,目前除了发布说明和 Git 变更记录外,没有其他渠道,但我们确实在认真考虑这个问题。

@th3coop 这些字段的移除已被撤销,因为这些字段被视为公开 API,详见 Discourse API Docs

感谢提醒,@tgxworld。我承认,API 在没有警告的情况下突然变更确实让人有些不安。

感谢迅速解决!

  • Carey