-
Notifications
You must be signed in to change notification settings - Fork 2.5k
fix(ask_user_question): add minLength/maxLength to header JSON Schema #4681
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
base: main
Are you sure you want to change the base?
Changes from all commits
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 | ||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -36,6 +36,24 @@ describe('AskUserQuestionTool', () => { | |||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| describe('JSON Schema', () => { | ||||||||||||||||||||||||||||||||||||||||||||||
| it('should enforce header maxLength 12 and minLength 1 in the schema', () => { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Collaborator
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. [Suggestion] Test name — qwen3.7-max via Qwen Code /review |
||||||||||||||||||||||||||||||||||||||||||||||
| const schema = tool.schema.parametersJsonSchema as Record< | ||||||||||||||||||||||||||||||||||||||||||||||
| string, | ||||||||||||||||||||||||||||||||||||||||||||||
| unknown | ||||||||||||||||||||||||||||||||||||||||||||||
| >; | ||||||||||||||||||||||||||||||||||||||||||||||
| const questions = (schema['properties'] ?? {}) as Record<string, unknown>; | ||||||||||||||||||||||||||||||||||||||||||||||
| const items = (questions['questions'] ?? {}) as Record<string, unknown>; | ||||||||||||||||||||||||||||||||||||||||||||||
| const questionProps = (items['items'] ?? {}) as Record<string, unknown>; | ||||||||||||||||||||||||||||||||||||||||||||||
| const header = (questionProps['properties'] ?? {}) as Record< | ||||||||||||||||||||||||||||||||||||||||||||||
| string, | ||||||||||||||||||||||||||||||||||||||||||||||
| unknown | ||||||||||||||||||||||||||||||||||||||||||||||
| >; | ||||||||||||||||||||||||||||||||||||||||||||||
| expect(header['maxLength']).toBe(12); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Collaborator
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. [Critical] Schema traversal stops one level too shallow. The variable Need one more traversal step to reach the actual header schema:
Suggested change
— qwen3.7-max via Qwen Code /review
Collaborator
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. [Critical] Schema traversal stops one level too shallow. The variable Add one more dereference step:
Suggested change
— qwen3.7-max via Qwen Code /review |
||||||||||||||||||||||||||||||||||||||||||||||
| expect(header['minLength']).toBe(1); | ||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| describe('validateToolParams', () => { | ||||||||||||||||||||||||||||||||||||||||||||||
| it('should accept valid params with single question', () => { | ||||||||||||||||||||||||||||||||||||||||||||||
| const params = { | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
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.
[Suggestion] Test name
"should enforce header maxLength 12 and minLength 1 in the schema"implies enforcement testing, but the test only reads static schema values — it doesn't exercise any validation path. Consider renaming to something like"should declare minLength and maxLength on header schema"to accurately reflect what's being asserted.— qwen3.7-max via Qwen Code /review