-
Notifications
You must be signed in to change notification settings - Fork 5
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
secretId 给错时不能正确给出错误信息。 #16
Comments
无法复现你说的问题,参考:https://repl.it/@WuYiqing/Manager-Node 请提供一个可以复现问题的 Demo。 |
@TeCHiScy 我的代码写错了,切换为上传文件的接口后,还是会报秘钥不存在,可以在新的 Demo 中查看: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
代码:
`
const { hosting, storage } = CloudBase.init({
secretId: "xxx",
secretKey: "xxx",
envId: "dev-xxx"
});
// 上传文件到 cos
await storage.uploadDirectory({
localPath: path.resolve("./content"),
cloudPath: "content",
onProgress: (data) => {
console.log(data);
},
});
`
这段代码中的 secretId 给错时报错为:
(node:10516) UnhandledPromiseRejectionWarning: TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string or an instance of Buffer or URL. Received undefined
at Object.stat (fs.js:1057:10)
at C:\Users\daren\Desktop\guanyuedesign.com\node_modules\cos-nodejs-sdk-v5\sdk\advance.js:828:12
at Object.each (C:\Users\daren\Desktop\guanyuedesign.com\node_modules\cos-nodejs-sdk-v5\sdk\util.js:248:13)
at COS.uploadFiles (C:\Users\daren\Desktop\guanyuedesign.com\node_modules\cos-nodejs-sdk-v5\sdk\advance.js:827:10)
at COS.uploadFiles (C:\Users\daren\Desktop\guanyuedesign.com\node_modules\cos-nodejs-sdk-v5\sdk\util.js:461:29)
at internal/util.js:297:30
at new Promise ()
at COS. (internal/util.js:296:12)
...
实际的错误是:
CloudBaseError: SIGN_PARAM_INVALID: secret key not exist
也就是 sdk 在用错误的 secretId 请求云 API 时返回的错误。
这层错误被 sdk 掩盖掉了,导致实际报出来的错误完全看不出和鉴权有关。
希望修复。
The text was updated successfully, but these errors were encountered: