Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4ac71e9

Browse files
authored
fix(codersdk/toolsdk): ensure all tools include required fields of aisdk.Schema (#17632)
1 parentef00ae5 commit4ac71e9

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

‎codersdk/toolsdk/toolsdk.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,7 @@ var ListWorkspaces = Tool[ListWorkspacesArgs, []MinimalWorkspace]{
327327
"description":"The owner of the workspaces to list. Use\"me\" to list workspaces for the authenticated user. If you do not specify an owner,\"me\" will be assumed by default.",
328328
},
329329
},
330+
Required: []string{},
330331
},
331332
},
332333
Handler:func(ctx context.Context,depsDeps,argsListWorkspacesArgs) ([]MinimalWorkspace,error) {
@@ -1256,6 +1257,7 @@ var DeleteTemplate = Tool[DeleteTemplateArgs, codersdk.Response]{
12561257
"type":"string",
12571258
},
12581259
},
1260+
Required: []string{"template_id"},
12591261
},
12601262
},
12611263
Handler:func(ctx context.Context,depsDeps,argsDeleteTemplateArgs) (codersdk.Response,error) {

‎codersdk/toolsdk/toolsdk_test.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,33 @@ func TestWithCleanContext(t *testing.T) {
539539
})
540540
}
541541

542+
funcTestToolSchemaFields(t*testing.T) {
543+
t.Parallel()
544+
545+
// Test that all tools have the required Schema fields (Properties and Required)
546+
for_,tool:=rangetoolsdk.All {
547+
t.Run(tool.Tool.Name,func(t*testing.T) {
548+
t.Parallel()
549+
550+
// Check that Properties is not nil
551+
require.NotNil(t,tool.Tool.Schema.Properties,
552+
"Tool %q missing Schema.Properties",tool.Tool.Name)
553+
554+
// Check that Required is not nil
555+
require.NotNil(t,tool.Tool.Schema.Required,
556+
"Tool %q missing Schema.Required",tool.Tool.Name)
557+
558+
// Ensure Properties has entries for all required fields
559+
for_,requiredField:=rangetool.Tool.Schema.Required {
560+
_,exists:=tool.Tool.Schema.Properties[requiredField]
561+
require.True(t,exists,
562+
"Tool %q requires field %q but it is not defined in Properties",
563+
tool.Tool.Name,requiredField)
564+
}
565+
})
566+
}
567+
}
568+
542569
// TestMain runs after all tests to ensure that all tools in this package have
543570
// been tested once.
544571
funcTestMain(m*testing.M) {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp