refactor(server): standardize tool error handling and status code mapping (#2402)

- Detect errors and return error codes accordingly in the tool call
handler functions.
- Replace the old `util.ErrUnauthorized` with the new Toolbox error
type.
This commit is contained in:
Wenxin Du
2026-02-12 11:42:27 -05:00
committed by GitHub
parent 32cb4db712
commit 32610d71a3
242 changed files with 3863 additions and 2720 deletions

View File

@@ -167,11 +167,10 @@ func TestCreateUsersToolEndpoints(t *testing.T) {
want: `{"name":"op2","status":"PENDING"}`,
},
{
name: "missing password for built-in user",
toolName: "create-user",
body: `{"project": "p1", "instance": "i1", "name": "test-user", "iamUser": false}`,
expectError: true,
errorStatus: http.StatusBadRequest,
name: "missing password for built-in user",
toolName: "create-user",
body: `{"project": "p1", "instance": "i1", "name": "test-user", "iamUser": false}`,
want: `{"error":"missing 'password' parameter for non-IAM user"}`,
},
}