Skip to content

Replace http-types with http #2233

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

Closed
wants to merge 1 commit into from
Closed

Conversation

ntrinquier
Copy link

As mentioned in #1937, http-types is not being maintained (and neither are some its dependencies).

This replaces it with the http crate which seems to be the ecosystem standard (10x more recent downloads).

@github-actions github-actions bot added Azure.Core The azure_core crate Azure.Identity The azure_identity crate Community Contribution Community members are working on the issue Cosmos The azure_cosmos crate customer-reported Issues that are reported by GitHub users external to the Azure organization. Storage Storage Service (Queues, Blobs, Files) labels Feb 25, 2025
Copy link

Thank you for your contribution @ntrinquier! We will review the pull request and get back to you soon.

@ntrinquier
Copy link
Author

@microsoft-github-policy-service agree company="Helsing"

@heaths
Copy link
Member

heaths commented Feb 25, 2025

This does get rid of a lot of older dependencies as well, since it seemed to pull in strict dependencies (probably using the older resolver; I never looked exactly). Might be worth it on that alone.

I'm still pondering on whether it's even worth it. Do we really need compatible types with other apps? Our generated clients are passing the right HTTP method. We do expose the StatusCode but could just as easily return our own. @ntrinquier is there any benefit to returning a common StatusCode in this case? I suppose I could see a web app "forwarding" the status on through their APIs, but we could always impl From common ones as well instead of actually returning someone else's. Sure, we still need a dependency in that case, could make it optional and, at the very least, not have our public API depend on someone else's type. That's how I'm leaning currently.

@analogrelay @LarryOsterman what do you think? To summarize, I'm leaning toward defining our own HTTP method enum (customers should never need to pass this anyway; it's public so our other crates can use it from azure_core) and defining our own StatusCode that can stay stable and we support From for http::StatusCode behind a feature flag (or not).

/cc @RickWinter @ronniegeraghty @JeffreyRichter

Copy link
Member

@heaths heaths left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution! I'm leaning toward taking this, in part, but reconsidering whether we even should expose third-party StatusCode from our error and response types. After GA, we have pretty strict no-breaking changes policy, though it's good to see that http did declare a 1.x stable release so, as long as they stick to semver, we should be stable.

Still, the only reason we expose Method from azure_core is because other crates need it to call into client methods. It's not meant to be truly customer public. StatusCode obviously is, but we could just as easily return our own with, optionally, From impls to http::StatusCode...perhaps behind a feature flag so the dependency is optional (if not already transitive) by default.

We'll talk internally about our public API shape, but I'd love to hear if you can think of any good reason to expose Method other than just having to since we have separate crates.

@@ -83,7 +83,7 @@ fe2o3-amqp-types = { version = "0.12" }
futures = "0.3"
getrandom = { version = "0.2", features = ["js"] }
hmac = { version = "0.12" }
http-types = { version = "2.12", default-features = false }
http = { version = "1.2", default-features = false }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on all the build errors, we need at least std.

@ntrinquier
Copy link
Author

is there any benefit to returning a common StatusCode in this case?

I'd love to hear if you can think of any good reason to expose Method

Not really, I went with the straightforward implementation which is a drop-in replacement, and so it preserves the status quo.

I do not see a problem with defining our own types, and in fact I think it would be nice to hide the dependency behind a feature flag by default, because new major versions of ubiquitous dependencies like http are always difficult to pick up.

Could you let me know after you get the chance to discuss internally? Then I can finalize the PR based on your feedback and guidance!

@heaths
Copy link
Member

heaths commented Feb 26, 2025

because new major versions of ubiquitous dependencies like http are always difficult to pick up.

True; however, I did check and we already have transitive dependencies on http anyway, so putting any From<> impl behind a feature flag would be moot.

@ntrinquier
Copy link
Author

@heaths just wanted to check whether you have some definitive guidance? :)

@heaths
Copy link
Member

heaths commented Mar 13, 2025

We're going to define our own StatusCode and probably Method as well. These are straight forward enough and given limited use, there's really no reason for a 3P dependency just for these. But I'm starting a major refactor of azure_core so I'll take the opportunity to define those as well.

heaths added a commit to heaths/azure-sdk-for-rust that referenced this pull request Mar 13, 2025
Resolves Azure#1644 and replaces Azure#2233. The latter PR was a good attempt but we decided internally we don't want to take a dependency on a different crate - `http` ; though, we do have a transitive dependency on it already - for something so simple.

This starts as a copy from http_types with appropriate attribution. We may want to remove a bunch of Methods we don't need, though, at some point.
@heaths
Copy link
Member

heaths commented Mar 13, 2025

Thanks for your work on this! Since we decided to define our own anyway, I started by copying - with attribution - the types from http_types we were already using. Makes for a smaller code change and I prefer enums for this purpose over constants anyway.

I opened #2331 which will replace this one.

@heaths heaths closed this Mar 13, 2025
@github-project-automation github-project-automation bot moved this from In Progress to Done in Azure Identity SDK Improvements Mar 13, 2025
heaths added a commit to heaths/azure-sdk-for-rust that referenced this pull request Mar 13, 2025
Resolves Azure#1644 and replaces Azure#2233. The latter PR was a good attempt but we decided internally we don't want to take a dependency on a different crate - `http` ; though, we do have a transitive dependency on it already - for something so simple.

This starts as a copy from http_types with appropriate attribution. We may want to remove a bunch of Methods we don't need, though, at some point.
@ntrinquier
Copy link
Author

Thanks for your work on this! Since we decided to define our own anyway, I started by copying - with attribution - the types from http_types we were already using. Makes for a smaller code change and I prefer enums for this purpose over constants anyway.

I opened #2331 which will replace this one.

No worries, happy to see a decision has been made, and I will be looking forward to the other MR being merged!

@ntrinquier ntrinquier deleted the nvt/http branch March 14, 2025 10:33
@heaths
Copy link
Member

heaths commented Mar 14, 2025

...though, we may end up having to use constants anyway. I've made StatusCode an "extensible enum" and we're discussing it internally (open to feedback externally as well, of course!), but several of us agree the DX on constants is just...bad.

heaths added a commit that referenced this pull request Mar 14, 2025
* Redefine Method, StatusCode from http_types in typespec

Resolves #1644 and replaces #2233. The latter PR was a good attempt but we decided internally we don't want to take a dependency on a different crate - `http` ; though, we do have a transitive dependency on it already - for something so simple.

This starts as a copy from http_types with appropriate attribution. We may want to remove a bunch of Methods we don't need, though, at some point.

* Change StatusCode to extensible enum

* Fix lint

* Remove unnecessary HTTP methods for Azure services
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Azure.Core The azure_core crate Azure.Identity The azure_identity crate Community Contribution Community members are working on the issue Cosmos The azure_cosmos crate customer-reported Issues that are reported by GitHub users external to the Azure organization. Storage Storage Service (Queues, Blobs, Files)
Projects
Development

Successfully merging this pull request may close these issues.

2 participants