Inaccurate conversion of big integer values
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 1.5k
- Forks
- 228
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 48
Description
Integer values close to INT64 maximum get unexpectedly changed to other values.
example-openapi-source.yaml:
openapi: 3.0.0
info:
title: Simple API
version: 1.0.0
paths:
/example:
get:
summary: Example endpoint
parameters:
- name: number
in: query
required: true
schema:
type: integer
format: int64
minimum: 0
maximum: 9223372036854775807
responses:
'200':
description: Successful response
To Reproduce
Steps to reproduce the behavior:
- Run
redocly bundle example-openapi-source.yaml -o example-openapi-redocly-output.yaml
Expected behavior
The value of maximum in example-openapi-redocly-output.yaml is the same as in example-openapi-source.yaml
Actual behavior
The value of maximum in example-openapi-redocly-output.yaml is equal to 9223372036854776000
Redocly Version(s)
1.6.0
Node.js Version(s)
v20.10.0
Additional context
It's caused by this line https://github.com/nodeca/js-yaml/blob/master/lib/type/int.js#L129
parseInt('9223372036854775807', 10) returns 9223372036854776000
JavaScript's maximum safe number is 9007199254740991, but in the openai config a larger number was used 9223372036854775807.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running redocly bundle example-openapi-source.yaml -o example-openapi-redocly-output.yaml and compare the maximum value with the source. Trace the bundle path and the linked js-yaml lib/type/int.js parsing behavior; done means the output preserves 9223372036854775807 without changing other integer handling.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- node.js, typescript
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100