Azure / Azure/openapi-diff

Runtime Exception - JSON integer is too large or small for an Int64

Đang mở
#258 1 bình luận 0 reaction 0 người được giao Xem trên GitHub
bug
Ngôn ngữ chính
C#
Star
290
Fork
50
Merge trung bình
5 ngày 13 giờ
Pull request đã merge (30 ngày)
5

Mô tả

I'm getting the follwing runtime exception when trying to run the tool against the following two files:
- https://github.com/Azure/azure-rest-api-specs/blob/4ee92e33cbdbec6685e3cfa125a9b80423cac04c/specification/confidentialledger/data-plane/Microsoft.ConfidentialLedger/stable/2022-11-23/confidentialledger.json
- https://github.com/Azure/azure-rest-api-specs/blob/main/specification/confidentialledger/data-plane/Microsoft.ConfidentialLedger/stable/2022-05-13/confidentialledger.json

```
Unhandled exception. Newtonsoft.Json.JsonReaderException: JSON integer 9223372036854776000 is too large or small for an Int64. Path 'parameters.CommitParameter.maximum', line 1, position 40197.
at Newtonsoft.Json.JsonTextReader.ParseNumber(ReadType readType)
at Newtonsoft.Json.JsonTextReader.ParseValue()
at Newtonsoft.Json.Linq.JContainer.ReadContentFrom(JsonReader r, JsonLoadSettings settings)
at Newtonsoft.Json.Linq.JContainer.ReadTokenFrom(JsonReader reader, JsonLoadSettings options)
at Newtonsoft.Json.Linq.JObject.Load(JsonReader reader, JsonLoadSettings settings)
at Newtonsoft.Json.Linq.JObject.Parse(String json, JsonLoadSettings settings)
at Newtonsoft.Json.Linq.JObject.Parse(String json)
at AutoRest.Swagger.JsonConverters.PathLevelParameterConverter..ctor(String json) in D:\a\1\s\openapi-diff\src\modeler\AutoRest.Swagger\PathLevelParameterConverter.cs:line 48
at AutoRest.Swagger.SwaggerParser.Parse(String swaggerDocument, String fileName) in D:\a\1\s\openapi-diff\src\modeler\AutoRest.Swagger\SwaggerParser.cs:line 22
at AutoRest.Swagger.SwaggerModeler.Compare(String fileNameOld, String swaggerOld, String fileNameNew, String swaggerNew, Settings settings) in D:\a\1\s\openapi-diff\src\modeler\AutoRest.Swagger\SwaggerModeler.cs:line 29
at OpenApiDiff.Program.Main(String[] args) in D:\a\1\s\openapi-diff\src\core\OpenApiDiff\Program.cs:line 37
Aborted

at ChildProcess.exithandler (node:child_process:389:12)
at ChildProcess.emit (node:events:513:28)
at maybeClose (node:internal/child_process:1091:16)
at Socket. (node:internal/child_process:449:11)
at Socket.emit (node:events:513:28)
at Pipe. (node:net:757:14) {
code: 134,
killed: false,
signal: null,
cmd: 'dotnet /home/apiccione/.nvm/versions/node/v18.6.0/lib/node_modules/@azure/oad/dlls/OpenApiDiff.dll -o /tmp/old-resolved.json -n /tmp/new-resolved.json',
stdout: '',
stderr: "Unhandled exception. Newtonsoft.Json.JsonReaderException: JSON integer 9223372036854776000 is too large or small for an Int64. Path 'parameters.CommitParameter.maximum', line 1, position 40197.\n" +
' at Newtonsoft.Json.JsonTextReader.ParseNumber(ReadType readType)\n' +
' at Newtonsoft.Json.JsonTextReader.ParseValue()\n' +
' at Newtonsoft.Json.Linq.JContainer.ReadContentFrom(JsonReader r, JsonLoadSettings settings)\n' +
' at Newtonsoft.Json.Linq.JContainer.ReadTokenFrom(JsonReader reader, JsonLoadSettings options)\n' +
' at Newtonsoft.Json.Linq.JObject.Load(JsonReader reader, JsonLoadSettings settings)\n' +
' at Newtonsoft.Json.Linq.JObject.Parse(String json, JsonLoadSettings settings)\n' +
' at Newtonsoft.Json.Linq.JObject.Parse(String json)\n' +
' at AutoRest.Swagger.JsonConverters.PathLevelParameterConverter..ctor(String json) in D:\\a\\1\\s\\openapi-diff\\src\\modeler\\AutoRest.Swagger\\PathLevelParameterConverter.cs:line 48\n' +
' at AutoRest.Swagger.SwaggerParser.Parse(String swaggerDocument, String fileName) in D:\\a\\1\\s\\openapi-diff\\src\\modeler\\AutoRest.Swagger\\SwaggerParser.cs:line 22\n' +
' at AutoRest.Swagger.SwaggerModeler.Compare(String fileNameOld, String swaggerOld, String fileNameNew, String swaggerNew, Settings settings) in D:\\a\\1\\s\\openapi-diff\\src\\modeler\\AutoRest.Swagger\\SwaggerModeler.cs:line 29\n' +
' at OpenApiDiff.Program.Main(String[] args) in D:\\a\\1\\s\\openapi-diff\\src\\core\\OpenApiDiff\\Program.cs:line 37\n' +
'Aborted\n'
}
```

This seems to originate from parsing the maximum int64 `9223372036854775807` [here](https://github.com/Azure/azure-rest-api-specs/blob/1fefe3f5cee88319b17c08a2dbf95e1e983a9f8c/specification/confidentialledger/data-plane/Microsoft.ConfidentialLedger/stable/2022-05-13/confidentialledger.json#L922), which for some reason gets converted to `9223372036854776000` when the tool runs. The value is the same for both specs.

Please also find more details about the error in the CI pipeline: https://github.com/Azure/azure-rest-api-specs/pull/21659/checks?check_run_id=9712102995.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Start with AutoRest.Swagger/PathLevelParameterConverter.cs at line 48, then follow SwaggerParser.Parse and the OpenApiDiff command shown in the report. Reproduce the failure with the linked ConfidentialLedger specifications. Done means the maximum value in parameters.CommitParameter can be processed without the Int64 parsing exception and the comparison completes.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
csharp
Lĩnh vực
cli
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.