注意
问题表单目前处于公开预览阶段,可能会有更改。
缺少必需的顶层键 name
模板中没有 name 字段,这意味着在向用户提供选项列表时,无法明确该 issue 模板的名称。
“缺少必需的顶层键 name”错误示例
description: "Thank you for reporting a bug!"
...
通过添加 name 键即可修复此错误。
name: "Bug report"
description: "Thank you for reporting a bug!"
...
key 必须是字符串
此错误信息表示提供了允许的键,但其值无法解析,因为数据类型不受支持。
“key 必须是字符串”错误示例
下面的 description 被解析为布尔值,但它应为字符串。
name: "Bug report"
description: true
...
通过提供字符串作为值即可修复此错误。字符串可能需要用双引号括起来才能正确解析。例如,包含 ' 的字符串必须使用双引号。
name: "Bug report"
description: "true"
...
当字段期望字符串时,空字符串或仅包含空白的字符串也不允许。
name: ""
description: "File a bug report"
assignees: " "
...
通过将值更正为非空字符串即可修复此错误。如果该字段不是必需的,请删除该键值对。
name: "Bug Report"
description: "File a bug report"
...
input 不是允许的键
模板的顶层提供了意外的键。有关支持的顶层键的更多信息,请参阅 issue 表单语法。
“input 不是允许的键”错误示例
name: "Bug report"
hello: world
...
通过删除意外的键即可修复此错误。
name: "Bug report"
...
禁用键
YAML 会将某些字符串解析为 Boolean 值。为避免这种情况,我们明确禁止使用以下键
y, Y, yes, Yes, YES, n, N, no, No, NO, true, True, TRUE, false, False, FALSE, on, On, ON, off, Off, OFF
通过删除禁用键即可修复此错误。
正文必须包含至少一个非 markdown 字段
issue 表单必须接受用户输入,这意味着至少有一个字段需为用户输入字段。markdown 元素是静态文本,故 body 数组不能只包含 markdown 元素。
“正文必须包含至少一个非 markdown 字段”错误示例
name: "Bug report"
body:
- type: markdown
attributes:
value: "Bugs are the worst!"
通过添加可接受用户输入的非 markdown 元素即可修复此错误。
name: "Bug report"
body:
- type: markdown
attributes:
value: "Bugs are the worst!"
- type: textarea
attributes:
label: "What's wrong?"
正文必须拥有唯一的 id
如果使用 id 属性来区分多个元素,则每个 id 必须唯一。
“正文必须拥有唯一的 id”错误示例
name: "Bug report"
body:
- type: input
id: name
attributes:
label: First name
- type: input
id: name
attributes:
label: Last name
通过更改其中一个输入的 id,使每个 input 字段拥有唯一的 id 属性,即可修复此错误。
name: "Bug report"
body:
- type: input
id: name
attributes:
label: First name
- type: input
id: surname
attributes:
label: Last name
正文必须拥有唯一的标签
当存在多个接受用户输入的 body 元素时,每个用户输入字段的 label 必须唯一。
“正文必须拥有唯一的标签”错误示例
name: "Bug report"
body:
- type: textarea
attributes:
label: Name
- type: textarea
attributes:
label: Name
通过更改其中一个输入字段的 label,确保每个 label>**都是唯一的**,即可修复此错误。
name: "Bug report"
body:
- type: textarea
attributes:
label: Name
- type: textarea
attributes:
label: Operating System
输入字段也可以通过其 id 属性来区分。如果需要重复的 label,可以为其中一个提供 id 来区分相同标签的两个元素。
name: "Bug report"
body:
- type: textarea
id: name_1
attributes:
label: Name
- type: textarea
id: name_2
attributes:
label: Name
id 属性在 issue 正文中不可见。如果希望在生成的 issue 中区分这些字段,请使用不同的 label 属性。
标签过于相似
相似的标签在生成引用时可能会被处理为相同的值。如果未为 input 提供 id,则使用 label 来生成对该 input 的引用。我们使用 Rails 的 parameterize 方法对 label 进行处理。在某些情况下,两个看似不同的标签会被参数化为相同的字符串。
“标签过于相似”错误示例
name: "Bug report"
body:
- type: input
attributes:
label: Name?
- type: input
id: name
attributes:
label: Name???????
通过在冲突的标签中加入至少一个字母数字字符、- 或 _,即可修复此错误。
name: "Bug report"
body:
- type: input
attributes:
label: Name?
- type: input
attributes:
label: Your name
也可以通过为冲突的标签中的其中一个赋予唯一的 id 来修复此错误。
name: "Bug report"
body:
- type: input
attributes:
label: Name?
- type: input
id: your-name
attributes:
label: Name???????
复选框必须拥有唯一的标签
当出现 checkboxes 元素时,其内部的每个标签必须在同层级以及其他输入类型中保持唯一。
“复选框必须拥有唯一的标签”错误示例
name: "Bug report"
body:
- type: textarea
attributes:
label: Name
- type: checkboxes
attributes:
options:
- label: Name
通过更改其中一个输入的 label 属性即可修复此错误。
name: "Bug report"
body:
- type: textarea
attributes:
label: Name
- type: checkboxes
attributes:
options:
- label: Your name
另外,也可以为任何冲突的顶层元素提供 id。嵌套的复选框元素不支持 id 属性。
name: "Bug report"
body:
- type: textarea
id: name_1
attributes:
label: Name
- type: checkboxes
attributes:
options:
- label: Name
id 属性在 issue 正文中不可见。如果希望在生成的 issue 中区分这些字段,请使用不同的 label 属性。
Body[i]:缺少必需的键 type
每个 body 块必须包含键 type。
针对 body 的错误会以 body[i] 为前缀,其中 i 表示出现错误的 body 块的零基索引。例如,body[0] 表示错误来自 body 列表中的第一个块。
“Body[i]:缺少必需的键 type”错误示例
body:
- attributes:
value: "Thanks for taking the time to fill out this bug! If you need real-time help, join us on Discord."
通过添加键 type 并将其值设为有效的输入类型即可修复此错误。有关可用的 body 输入类型及其语法,请参阅 GitHub 表单模式语法。
body:
- type: markdown
attributes:
value: "Thanks for taking the time to fill out this bug! If you need real-time help, join us on Discord."
Body[i]: x 不是有效的输入类型
某个 body 块的 type 值不属于 允许的类型。
针对 body 的错误会以 body[i] 为前缀,其中 i 表示出现错误的 body 块的索引。例如,body[0] 表示错误来自 body 列表中的第一个块。
“Body[i]: x 不是有效的输入类型”错误示例
body:
- type: x
attributes:
value: "Thanks for taking the time to fill out this bug! If you need real-time help, join us on Discord."
通过将 x 更改为有效的类型即可修复此错误。
body:
- type: markdown
attributes:
value: "Thanks for taking the time to fill out this bug! If you need real-time help, join us on Discord."
Body[i]:缺少必需属性键 value
某个必需的 value 属性未提供。当块缺少 attributes 键或在 attributes 键下缺少 value 键时会出现此错误。
针对 body 的错误会以 body[i] 为前缀,其中 i 表示出现错误的 body 块的索引。例如,body[0] 表示错误来自 body 列表中的第一个块。
“Body[i]: 缺少必需属性键 value”错误示例
body:
- type: markdown
attributes:
value: "Thanks for taking the time to fill out this bug! If you need real-time help, join us on Discord."
- type: markdown
在本示例中,只需在 body 的第二个列表元素的 attributes 下添加 value 键即可修复错误。
body:
- type: markdown
attributes:
value: "Thanks for taking the time to fill out this bug! If you need real-time help, join us on Discord."
- type: markdown
attributes:
value: "This is working now!"
Body[i]: 标签必须是字符串
在其 attributes 块中,某个值的数据类型错误。
针对 body 的错误会以 body[i] 为前缀,其中 i 表示出现错误的 body 块的索引。例如,body[0] 表示错误来自 body 列表中的第一个块。
“Body[i]: 标签必须是字符串”错误示例
下面的 label 被解析为布尔值,但它应为字符串。
body:
- type: markdown
attributes:
value: "Thanks for taking the time to fill out this bug! If you need real-time help, join us on Discord."
- type: textarea
attributes:
label: Bug Description
- type: textarea
attributes:
label: true
通过为 label 提供字符串值即可修复此错误。如果希望使用的 label 值可能被解析为布尔、整数或小数,请将其用引号括起来。例如,用 "true" 或 "1.3" 替代 true 或 1.3。
- type: markdown
attributes:
value: "Thanks for taking the time to fill out this bug! If you need real-time help, join us on Discord."
- type: textarea
attributes:
label: Bug Description
- type: textarea
attributes:
label: Environment Details
空字符串或仅包含空白的字符串在属性期望字符串时均不允许。例如,"" 或 " " 都不被接受。
如果属性为必需,则值必须为非空字符串;如果字段不是必需的,请删除该键值对。
body:
- type: input
attributes:
label: "Name"
Body[i]: id 只能包含数字、字母、-、_
id 属性只能包含字母数字字符、- 与 _。您的模板可能在 id 中包含了不允许的字符,例如空格。
针对 body 的错误会以 body[i] 为前缀,其中 i 表示出现错误的 body 块的索引。例如,body[0] 表示错误来自 body 列表中的第一个块。
“Body[i]: id 只能包含数字、字母、-、_”错误示例
name: "Bug report"
body:
- type: input
id: first name
attributes:
label: First name
通过确保从 id 值中移除空格及其他不允许的字符即可修复此错误。
name: "Bug report"
body:
- type: input
id: first-name
attributes:
label: First name
Body[i]: x 不是允许的键
在与 type 和 attributes 相同缩进级别意外提供了键 x。
针对 body 的错误会以 body[i] 为前缀,其中 i 表示出现错误的 body 块的索引。例如,body[0] 表示错误来自 body 列表中的第一个块。
“Body[i]: x 不是允许的键”错误示例
body:
- type: markdown
x: woof
attributes:
value: "Thanks for taking the time to fill out this bug! If you need real-time help, join us on Discord."
通过删除多余的键,仅保留 type、attributes 与 id 即可修复此错误。
body:
- type: markdown
attributes:
value: "Thanks for taking the time to fill out this bug! If you need real-time help, join us on Discord."
Body[i]: label 包含禁用词
为降低在 GitHub Issues 中公开发布私人信息和凭据的风险,某些常被攻击者使用的词汇在 input 或 textarea 元素的 label 中被禁止使用。
针对 body 的错误会以 body[i] 为前缀,其中 i 表示出现错误的 body 块的索引。例如,body[0] 表示错误来自 body 列表中的第一个块。
“Body[i]: label 包含禁用词”错误示例
body:
- type: markdown
attributes:
value: Hello world!
- type: input
attributes:
label: Password
通过从所有 label 字段中移除类似 “password” 等词汇即可修复此错误。
body:
- type: markdown
attributes:
value: Hello world!
- type: input
attributes:
label: Username
Body[i]: x 不是允许的属性
在 attributes 块中提供了无效的键。
针对 body 的错误会以 body[i] 为前缀,其中 i 表示出现错误的 body 块的索引。例如,body[0] 表示错误来自 body 列表中的第一个块。
“Body[i]: x 不是允许的属性”错误示例
body:
- type: markdown
attributes:
x: "a random key!"
value: "Thanks for taking the time to fill out this bug!"
通过删除多余的键,仅使用被允许的属性即可修复此错误。
body:
- type: markdown
attributes:
value: "Thanks for taking the time to fill out this bug!"
Body[i]: options 必须唯一
对复选框和下拉输入类型而言,options 数组中定义的选项必须唯一。
针对 body 的错误会以 body[i] 为前缀,其中 i 表示出现错误的 body 块的索引。例如,body[0] 表示错误来自 body 列表中的第一个块。
“Body[i]: options 必须唯一”错误示例
body:
- type: dropdown
attributes:
label: Favorite dessert
options:
- ice cream
- ice cream
- pie
确保 options 数组中不存在重复选项即可修复此错误。
body:
- type: dropdown
attributes:
label: Favorite dessert
options:
- ice cream
- pie
Body[i]: options 不能包含保留词 none
“None” 是 options 集合中的保留词,因为在下拉框不是必需时,它用于表示不选择任何选项。
针对 body 的错误会以 body[i] 为前缀,其中 i 表示出现错误的 body 块的索引。例如,body[0] 表示错误来自 body 列表中的第一个块。
“Body[i]: options 不能包含保留词 none”错误示例
body:
- type: dropdown
attributes:
label: What types of pie do you like?
options:
- Steak & Ale
- Chicken & Leek
- None
validations:
required: true
通过移除 “None” 选项即可修复此错误。如果希望贡献者能够表示他们不喜欢任何这些馅饼类型,还可以去掉 required 验证。
body:
- type: dropdown
attributes:
label: What types of pie do you like?
options:
- Steak & Ale
- Chicken & Leek
在本示例中,“None” 将自动作为可选项出现。
Body[i]: options 不能包含布尔值。请将诸如 'yes'、'true' 等值用引号括起来
除非用引号括起,否则 YAML 解析器会将若干英文单词处理为布尔值。对于下拉 options,所有项必须为字符串而非布尔值。
针对 body 的错误会以 body[i] 为前缀,其中 i 表示出现错误的 body 块的索引。例如,body[0] 表示错误来自 body 列表中的第一个块。
“Body[i]: options 不能包含布尔值。请将诸如 'yes'、'true' 等值用引号括起来”错误示例
body:
- type: dropdown
attributes:
label: Do you like pie?
options:
- Yes
- No
- Maybe
通过为每个违规的选项加上引号,防止它们被当作布尔值处理,即可修复此错误。
body:
- type: dropdown
attributes:
label: Do you like pie?
options:
- "Yes"
- "No"
- Maybe
正文不能为空
模板正文的 key:value 对不能为空。有关必需的顶层键的更多信息,请参阅 issue 表单语法。
通过添加 body: 部分即可修复此错误。
“正文不能为空”错误示例
name: Support Request
description: Something went wrong and you need help?
---
body:
- type: textarea
attributes:
label: "What's wrong?"
在本示例中,删除标题与 body 部分之间的 ---(文档分隔符)即可修复错误。
name: Support Request
description: Something went wrong and you need help?
body:
- type: textarea
attributes:
label: "What's wrong?"