Fix #367: MCP工具错误: createFunction#473
Fix #367: MCP工具错误: createFunction#473JiwaniZakir wants to merge 1 commit intoTencentCloudBase:mainfrom
Conversation
|
Thanks for your work I don't think this actually fixes #367. isWaitInstall does exist in @cloudbase/manager-node, but in the current 5.0.0 contract it is part of func, not a top-level field of createFunction(...). The SDK's createFunction implementation only destructures { func, functionRootPath, force, base64Code, functionPath, codeSecret, deployMode } from the top level, so the newly added top-level isWaitInstall here is very likely ignored at runtime. Because of that, the new test is currently only proving that our mock received a top-level field, not that the real SDK behavior changed or that #367 is actually fixed. I think this should either: be fixed in @cloudbase/manager-node and then consumed here via a version bump, or |
Closes #367
Passes
isWaitInstallthrough to the underlyingcreateFunctioncall when the caller explicitly provides it.Changes
mcp/src/tools/functions.ts— In theregisterFunctionToolshandler'screateFunctionaction, a conditional spread...(func.isWaitInstall !== undefined && { isWaitInstall: func.isWaitInstall })was added to the options object passed tocreateFunction. Previously,isWaitInstallwas silently dropped even when supplied infunc, so the dependency installation wait behavior was never forwarded to the API.mcp/src/tools/functions.test.ts— Added a test case that calls thecreateFunctionaction withisWaitInstall: falseand asserts thatmockCreateFunctionreceives an object containingisWaitInstall: false, confirming the field is no longer swallowed.Motivation
Users setting
isWaitInstall: false(ortrue) in thefuncparameter received a misleading依赖安装失败(dependency install failed) error because the field was never forwarded to the CloudBase API. Thefuncobject was destructured and passed through, but the explicitcreateFunctioncall infunctions.tsonly spreadfunc,functionRootPath, andforce— omitting anyisWaitInstallvalue. The conditional spread fixes this without breaking callers that omit the field entirely (theundefinedguard prevents injecting a spuriousisWaitInstall: undefined).Testing
The new unit test in
functions.test.tsdirectly covers the fix: it invokes the handler withisWaitInstall: falseand verifies viaexpect(mockCreateFunction).toHaveBeenCalledWith(expect.objectContaining({ isWaitInstall: false })). This test would have failed against the previous code, confirming the regression is caught.This PR was created with AI assistance (Claude). The changes were reviewed by quality gates and a critic model before submission.