Skip to content

Azure cosmos API is locale dependent when sending RFC 1123 dates #29109

@MadJlzz

Description

@MadJlzz
  • Package Name: azure-cosmos
  • Package Version: 4.3.1
  • Operating System: Linux
  • Python Version: 3.9.5

Describe the bug
Azure Cosmos API expects a RFC 1123 date format. When the format is wrong, we are receiving:

Message: The input date header is invalid format. Please pass in RFC 1123 style date format.

from the server.

Headers of the request are build within the library:

if cosmos_client_connection.master_key:
headers[http_constants.HttpHeaders.XDate] = datetime.datetime.utcnow().strftime("%a, %d %b %Y %H:%M:%S GMT")

The problem I have is that my personal locale is not English. It's Luxemburgish. That being said, datetime.datetime.utcnow().strftime("%a, %d %b %Y %H:%M:%S GMT") will return a date with the given format that is following my locale Do, 02 Mär 2023 16:43:01 GMT instead of Thu, 02 Mar 2023 16:43:01 GMT

This breaks the server and we get a exceptions.CosmosHttpResponseError error at the client level.

To Reproduce
Steps to reproduce the behavior:

  1. Switch your locale to Luxemburgish (didn't try to put a different one)
  2. Initialize a CosmosClient
  3. Do a call to the API ; in my case ; list_databases()
  4. Dramatic explosion

Expected behavior
I let you guys decide what would be the best way to fix that but personally I would either force the date generation with an hard coded locale (not the best) or make the locale transparent on the server side.

Hopefully I am being clear 😄

Metadata

Metadata

Assignees

Labels

Cosmoscustomer-reportedIssues that are reported by GitHub users external to the Azure organization.issue-addressedWorkflow: The Azure SDK team believes it to be addressed and ready to close.questionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions