MindFlavor / AzureSDKForRust

Microsoft Azure SDK for Rust
http://mindflavor.github.io/AzureSDKForRust
Apache License 2.0
160 stars 62 forks source link

ParseIntError - Response header has negative value #267

Closed neshanthan closed 4 years ago

neshanthan commented 4 years ago

I am using the Cosmos DB emulator.

When I create a collection document, the value of the x-ms-global-committed-lsn header in the response is -1.

The header is expected to be u64 so it is throwing a ParseIntError.

I can't find documentation for what the expected values are for this header / what it means.

If anyone is aware of an appropriate type I can submit a pull request.

MindFlavor commented 4 years ago

The x-ms-global-committed-lsn tracks the minimum committed LSN across all regions (at least that's my understanding, don't quote me on that! :open_hands:). It's understandable that the emulator does not have this value. It seems the implementation uses -1 as "lack of value".

Probably the correct solution is to map -1 as None. That means changing the type to Option<_>. I dislike this solution because it will unnecessarily complicate things for the on-cloud CosmosDB.

I'm partial to mapping -1 to 0 instead. This will make Rust happy without complicating things. What do you think? It's an useless value for the emulator anyway.

neshanthan commented 4 years ago

Thanks for the explanation that makes sense :smile:

Originally I wasn't sure if it was specific to the emulator. I agree with mapping-1 to 0 as it will only affect emulator and the value won't be used.