Skip to content

oss ListObjects 服务器响应的是 xml,gateway-oss 在只有一个对象时 parseXml 解析结果的不是数组,会报错 type of contents is mismatch, expect array, but object #25

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

Closed
ganlvtech opened this issue Mar 28, 2024 · 1 comment

Comments

@ganlvtech
Copy link

node_modules/@alicloud/gateway-oss/src/client.ts:207 (gateway-oss 这个仓库还没有上传 GitHub)

    let result : {[key: string ]: any} = XML.parseXml(bodyStr, null);

因为 ListObjects 返回结果里只有一个 标签,这行 parseXml 解析的结果 contents 就是一个 Content Object 而不是 Array

然后在
https://github.com/aliyun/tea-typescript/blob/1.x/src/tea.ts#L329

        } else if (type.type === 'array') {
            if (!Array.isArray(value)) {
                throw new Error(`type of ${key} is mismatch, expect array, but ${typeof value}`);
            }

contents 的 type.type 是 'array',但是 parseXml 因为只有一个 标签,本来应该是 array 但是解析成 object 了,这行旧 throw Error 了
Uncaught Error: type of contents is mismatch, expect array, but object

@TsinghuaDream
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants