aliyun / aliyun/aliyun-openapi-java-sdk

sas - DescribePropertySoftwareDetail bug

Open
#454 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
1.4k
Forks
1.1k
PR merge metrics
No merged PRs in 30d

Description

_

  • 产品和接口: SAS(云安全中心态势感知) SDK version:1.1.1 DescribePropertySoftwareDetail 接口
  • 平台:任意平台
  • 最小代码:
    由 OpenAPI Explorer自动生成
import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.exceptions.ServerException;
import com.aliyuncs.profile.DefaultProfile;
import com.google.gson.Gson;
import java.util.*;
import com.aliyuncs.sas.model.v20181203.*;

public class DescribePropertySoftwareDetail {

    public static void main(String[] args) {
        DefaultProfile profile = DefaultProfile.getProfile("cn-hangzhou", "<accessKeyId>", "<accessSecret>");
        IAcsClient client = new DefaultAcsClient(profile);

        DescribePropertySoftwareDetailRequest request = new DescribePropertySoftwareDetailRequest();
        request.setRegionId("cn-hangzhou");
        request.setRemark("xxx");
        request.setName("docker");

        try {
            DescribePropertySoftwareDetailResponse response = client.getAcsResponse(request);
            System.out.println(new Gson().toJson(response));
        } catch (ServerException e) {
            e.printStackTrace();
        } catch (ClientException e) {
            System.out.println("ErrCode:" + e.getErrCode());
            System.out.println("ErrMsg:" + e.getErrMsg());
            System.out.println("RequestId:" + e.getRequestId());
        }

    }
}

报错如下:
Exception in thread "main" java.lang.NumberFormatException: For input string: "2020-06-30T13:24Z"
at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.base/java.lang.Long.parseLong(Long.java:692)
at java.base/java.lang.Long.valueOf(Long.java:1144)
at com.aliyuncs.transform.UnmarshallerContext.longValue(UnmarshallerContext.java:31)
at com.aliyuncs.sas.transform.v20181203.DescribePropertySoftwareDetailResponseUnmarshaller.unmarshall(DescribePropertySoftwareDetailResponseUnmarshaller.java:46)
at com.aliyuncs.sas.model.v20181203.DescribePropertySoftwareDetailResponse.getInstance(DescribePropertySoftwareDetailResponse.java:226)
at com.aliyuncs.sas.model.v20181203.DescribePropertySoftwareDetailResponse.getInstance(DescribePropertySoftwareDetailResponse.java:26)
at com.aliyuncs.DefaultAcsClient.readResponse(DefaultAcsClient.java:364)
at com.aliyuncs.DefaultAcsClient.parseAcsResponse(DefaultAcsClient.java:201)
at com.aliyuncs.DefaultAcsClient.getAcsResponse(DefaultAcsClient.java:117)
at com.company.Main.main(Main.java:151)
_

经查看 SDK com.aliyuncs.sas.model.v20181203 DescribePropertySoftwareDetailResponse 类定义

 public static class PropertySoftware {
        private String name;
        private String path;
        private String instanceName;
        private String ip;
        **private Long create;**
        private Long createTimestamp;
        private String installTime;
        private String version;
        private String uuid;
        private String instanceId;
        private String intranetIp;
        private String internetIp;

其中 create 为 Long,但通过 OpenAPI Explorer 测试结果来看返回的数据如下
"Propertys": [
{
"Path": "/etc/docker",
"InstanceName": "数据脱敏",
"Uuid": "数据脱敏",
"InternetIp": "",
"InstallTime": "2019-08-30 04:00:54",
"Version": "1.13.1",
"InstanceId": "数据脱敏",
"Create": "2020-06-30T13:24Z",
"Ip": "数据脱敏",
"CreateTimestamp": 1593494653000,
"IntranetIp": "数据脱敏",
"Name": "docker"
},

可以看到 Create 返回的是一个字符串形式的UTC时间,导致 DescribePropertySoftwareDetailResponse 数据类型转换出错。

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with com.aliyun.sas.model.v20181203.DescribePropertySoftwareDetailResponse and its DescribePropertySoftwareDetailResponseUnmarshaller, following the stack trace to the conversion of PropertySoftware.Create. Reproduce with the OpenAPI Explorer example or the provided Java request, then verify that the response parses the UTC timestamp without a NumberFormatException.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.