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

Replace http-types with http #2233

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

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.

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
Status: In Progress
Development

Successfully merging this pull request may close these issues.

2 participants