Skip to content
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

Feature request: Honor order of metadata keys #613

Closed
dramirez-tc opened this issue Sep 12, 2019 · 3 comments · Fixed by #614
Closed

Feature request: Honor order of metadata keys #613

dramirez-tc opened this issue Sep 12, 2019 · 3 comments · Fixed by #614

Comments

@dramirez-tc
Copy link

dramirez-tc commented Sep 12, 2019

Would it be possible to honor the order of metadata keys? We rely on a lot of metadata and the ordering is important. In our case alphabetical. An OrderedDict is passed to Charge.create() but it looks like the ordering gets lost in the api_requestor.py:_encode_nested_dict() func. Perhaps instead of

d {}
from collections import OrderedDict
d = OrderedDict()

Maybe there's a more clever way to handle that.

@ob-stripe
Copy link
Contributor

Hi @dramirez-tc.

I would personally advise against relying on a specific order for metadata keys. Stripe's API makes no guarantee around key order, and if I'm not mistaken returns metadata keys in alphabetical order, not insertion order. In any case, the ordering is more of an implementation detail than a formal contract.

Nevertheless, I've opened a PR for this (#614) as I think maintaining order in API requests and responses makes the client library more consistent and easier to reason around.

@ob-stripe
Copy link
Contributor

Fixed in 2.36.2.

@dramirez-tc
Copy link
Author

Thank you so much! It's so refreshing to work for a company that really listens! Mwah!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants