-
Notifications
You must be signed in to change notification settings - Fork 280
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
Ensure returned versionId is a string when listing objects #1193
Conversation
maybe #1133 ? |
I don't think so, in my case versionIds are in base 10: > const { XMLParser } = require("fast-xml-parser")
undefined
> const fxp = new XMLParser({
... numberParseOptions: {
... leadingZeros: false,
... hex: false,
... }
... })
undefined
> fxp.parse('<Key>0x2f</Key>') // results in string as expected
{ Key: '0x2f' }
> fxp.parse('<Key>1234</Key>') // This number encoded in base 10 results in number, I would like to force them to be string for versionId
{ Key: 1234 } |
then I think we should create a new parser and disable auto number parsing, and parse when needed, not convert it back to string... |
There are some case it is relevant to convert values to numbers, like for size. Should we then convert numbers manually? |
Yes, what I mean |
fox example, |
Right, however, the only way I found to discard automatic conversion is to use the const parseXml = new XMLParser({
numberParseOptions: {
skipLike: /./
}
}) Documentation of numberParseOption: https://github.com/NaturalIntelligence/fast-xml-parser/blob/edb30ddefb9c131a724761b5f79cd4f883736214/docs/v4/2.XMLparseOptions.md#numberparseoptions Related issue: NaturalIntelligence/fast-xml-parser#516 Is it fine for you? |
yes, looks fine |
e01ed9d
to
4552f57
Compare
Done! I did not make the same change for parseListObjectsV2 and parseListObjectsV2WithMetadata API as they don't have VersionId attribute to handle and keys / prefixes are parsed as string. Do you think it's worth to make the same change as well despite of this? |
4552f57
to
c1e1db3
Compare
Returned versionId is a string when calling statObject(), as it is read without transformation (casting) from the headers. However, the xml parser casts automatically what looks like a number in the responses. Consequentially, when the S3 storage provider returns a VersionId with only numbers, listObjects() returns an object with a versionId as a number, which is inconsistent with what returns other methods like statObjects() and may result in erratic behaviors for the program using these methods.
04fee27
to
28478ee
Compare
Returned versionId is a string when calling statObject(), as it is read without transformation (casting) from the headers.
However, the xml parser casts automatically what looks like a number in the responses. Consequentially, when the S3 storage provider returns a VersionId with only numbers, listObjects() returns an object with a versionId as a number, which is inconsistent with what returns other methods like statObjects() and may result in erratic behaviors for the program using these methods.