-
Notifications
You must be signed in to change notification settings - Fork 419
Handle string-form create_issue.labels across safe-output validation and schema/tool definitions
#38738
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle string-form create_issue.labels across safe-output validation and schema/tool definitions
#38738
Changes from all commits
b83bf00
a7072a6
cc6361c
984a91d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -873,6 +873,15 @@ describe("safe_output_type_validator", () => { | |
| expect(Array.isArray(result.normalizedItem.labels)).toBe(true); | ||
| }); | ||
|
|
||
| it("should normalize comma-separated labels string to array", async () => { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Test coverage gap: only 💡 Suggested additionsAdd at least these cases: // Verify the normalization is intentional for add_labels
it("should normalize comma-separated labels string for add_labels", async () => {
const { validateItem } = await import("./safe_output_type_validator.cjs");
const result = validateItem({ type: "add_labels", labels: "bug, enhancement" }, "add_labels", 1);
expect(result.isValid).toBe(true);
expect(result.normalizedItem.labels).toEqual(["bug", "enhancement"]);
});
// Guard against empty-string silent pass for a required array field
it("should reject empty string for required labels field", async () => {
const { validateItem } = await import("./safe_output_type_validator.cjs");
const result = validateItem({ type: "add_labels", labels: "" }, "add_labels", 1);
expect(result.isValid).toBe(false); // fails today — empty array passes required check
});The second test will fail with the current code, surfacing the empty-string issue noted on the normalization block. |
||
| const { validateItem } = await import("./safe_output_type_validator.cjs"); | ||
|
|
||
| const result = validateItem({ type: "create_issue", title: "Test", body: "Detailed issue body text.", labels: "reliability, telemetry" }, "create_issue", 1); | ||
|
|
||
| expect(result.isValid).toBe(true); | ||
| expect(result.normalizedItem.labels).toEqual(["reliability", "telemetry"]); | ||
| }); | ||
|
|
||
| it("should reject array with non-string items", async () => { | ||
| const { validateItem } = await import("./safe_output_type_validator.cjs"); | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Empty-string input silently produces an empty array and passes required-field validation:
labels: ""→split(",")→[""]→filter(Boolean)→[].Array.isArray([])istrue, soadd_labels.labels(which isrequired: true) will pass validation with an empty labels list.💡 Impact and fix
An
add_labelscall withlabels: ""passes the JS validator but then silently does nothing at the GitHub API level (zero labels to add). The operator sees no error but no label is applied.The fix is to reject normalised-empty results when the field is required:
Alternatively, add a
minItems: 1check to the general array validation path for any required array field.