今日英文表达 2/30 · 阶段:开启 Issue。 所有例句均为本文虚构。并非摘自实际仓库的评论,版本和命令仅为示例。
目录
概览
| 表达 | Expected behavior / Actual behavior, What did you expect to happen? |
| 含义 | 期望的行为 / 实际的行为,原本应该发生什么? |
| 使用场景 | Bug Issue 正文、Issue 模板、要求复现的评论 |
| 礼貌程度 | 中立。由于采用分段记录事实的形式,不带任何情绪 |
1. 含义与语感
在 Bug 报告中,维护者最想了解的两件事是: 实际发生了什么(actual behavior),以及 报告者认为应该发生什么(expected behavior)。两者之间的差距就是 Bug 的定义。如果你的期望与文档不同,这可能不是 Bug 而是误解,所以如果把期望单独写出来,维护者就能更快地回复“这是预期的行为”。
Kubernetes 的 Bug 报告模板将前三个格子设为 What happened?, What did you expect to happen?, How can we reproduce it (as minimally and precisely as possible)?。许多仓库都采用这种结构。即使是没有模板的仓库,直接使用这三个标题也能写出一个易读的 Issue。
请注意时态。由于实际行为是已经发生的事情,因此要使用过去时(The pod was evicted)或现在时(The controller logs an error)。对于期望的行为,请使用 should 或 expected ... to (The VM should stay running, I expected the backup to complete)。
2. 例句
情况 1:Issue 正文的两个格子
What happened: After upgrading to v1.3.0,
virtctl restartreturns immediately, but the VM stays inStopped.What did you expect to happen: The VM should be restarted and reach
Running, as it did on v1.2.x.
补充说明在之前的版本中是如何表现的(as it did on v1.2.x),可以立即暴露出这是一个回归(regression)问题。
情况 2:将 Expected 和 Actual 作为小标题分开时
Expected behavior
The scheduled backup completes and a new object appears in the bucket.
Actual behavior
The backup stays in
runningfor more than an hour, and no object is written.
情况 3:在别人的 Issue 下提问时
Thanks for the report. Could you clarify what you expected to happen here? The current behavior matches the docs, so I want to make sure I understand the use case.
提问的一方也会使用这个表达。这是一种礼貌地确认期望、不具攻击性的方法。
3. 相似表达与区别
- Steps to reproduce. 复现步骤。这是介于期望与实际之间的格子,用带编号的列表写出命令。
- Observed behavior. 与 actual behavior 意思相同。稍微更正式一些,且“观察到的事实”这一语感更强。
- Desired behavior. 用于功能请求(feature request)。Bug 报告中的 expected 指的是“原本应该这样的事”,而 desired 指的是“希望以后能这样的事”。
4. 韩国人常犯的错误
- It doesn't work. 这种单行报告会让维护者反复追问两三次。必须写清楚是什么东西、以何种方式无法正常工作。
- 修改后的句子:The webhook rejects valid manifests with
field is immutable. I expected the update to be accepted because only the label changed.
- 修改后的句子:The webhook rejects valid manifests with
- I expected that it will be restarted. 时态不匹配。由于是对过去的期望,应该使用 would 或不定式 to。
- 修改后的句子:I expected it to be restarted.
- Expected result is VM is running. 缺少冠词和连接词,导致句子断开。
- 修改后的句子:The expected result is that the VM is running.
- Please kindly check this bug ASAP. 混合了催促和过度的客套。如果影响很大,请直接陈述影响这一事实。
- 修改后的句子:This blocks upgrades for clusters using the default storage class.
5. 一行练习
请将以下内容分成 Issue 的两个格子,并用英文书写。
我删除了备份策略,但预定的备份仍在不断创建。我认为删除策略后,预定备份也应该停止。
参考答案
What happened: After deleting the backup policy, scheduled backups are still being created.
What did you expect to happen: Deleting the policy should stop the scheduled backups.
are still being created 是“现在仍在继续被创建”的进行时被动语态。后一句因为表达的是“应该……”的期望,所以使用 should。
Titi 小贴士。 只要把期望的事情和实际发生的事情分成两行来写,Bug 报告就已经完成了一半。
参考
- Kubernetes Bug 报告模板(bug-report.yaml): https://github.com/kubernetes/kubernetes/blob/master/.github/ISSUE_TEMPLATE/bug-report.yaml
- GitHub Docs, 配置 Issue 模板: https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/configuring-issue-templates-for-your-repository