feat: Introduce the templated_uri crate family#265
Conversation
|
064cc90 to
5153dc6
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #265 +/- ##
========================================
- Coverage 100.0% 99.8% -0.2%
========================================
Files 141 156 +15
Lines 8640 10828 +2188
========================================
+ Hits 8640 10816 +2176
- Misses 0 12 +12 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
00578d3 to
c21aef9
Compare
# Conflicts: # .spelling
530fefd to
4dde26f
Compare
4dde26f to
01b8ba5
Compare
fe5df3f to
73be0ad
Compare
73be0ad to
f1c4899
Compare
|
Note that the logo I designed for when the crate was named "obscuri". The new name warrants a new logo. Also, you should update the PR title. |
|
Here are a bunch of things the AI recommends fixing: Analysis of
|
There was a problem hiding this comment.
Pull request overview
This PR introduces a new crate family for standards-compliant URI handling with templating, safety validation, and data classification support. However, there is a significant naming discrepancy: the PR title and description reference "obscuri" while the actual crate names are "templated_uri", "templated_uri_macros", and "templated_uri_macros_impl". The implementation provides RFC 6570 Level 3 compliant URI templating with compile-time safety guarantees and integration with the data_privacy crate for redaction support.
Changes:
- Adds three new crates:
templated_uri,templated_uri_macros, andtemplated_uri_macros_impl - Implements RFC 6570 URI templates with derive macros for type-safe URI construction
- Provides
UriSafetrait and validation to prevent URI injection vulnerabilities
Reviewed changes
Copilot reviewed 39 out of 40 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/templated_uri/src/lib.rs | Main library module with core types and re-exports |
| crates/templated_uri/src/uri.rs | Uri type implementation with templating support |
| crates/templated_uri/src/uri_safe.rs | UriSafe trait and validation logic |
| crates/templated_uri/src/uri_fragment.rs | Fragment traits for URI template parameters |
| crates/templated_uri/src/base_uri.rs | BaseUri type for scheme and authority handling |
| crates/templated_uri_macros/src/lib.rs | Procedural macro entry points |
| crates/templated_uri_macros_impl/src/lib.rs | Core macro implementation logic |
| crates/templated_uri_macros_impl/src/template_parser.rs | RFC 6570 template parser using chumsky |
| crates/templated_uri_macros_impl/src/struct_template.rs | Struct template macro implementation |
| crates/templated_uri_macros_impl/src/enum_template.rs | Enum template macro implementation |
| crates/templated_uri_macros_impl/src/uri_fragment.rs | Derive macro for UriFragment traits |
| Cargo.toml | Workspace dependency additions |
| README.md | Updated with new crate reference (naming issue) |
| CHANGELOG.md | Updated with new crate references (naming issues) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| repository = "https://github.com/microsoft/oxidizer/tree/main/crates/templated_uri" | ||
|
|
||
| [package.metadata.cargo_check_external_types] | ||
| allowed_external_types = [ |
There was a problem hiding this comment.
I worry that we're having to expose all of these external types here. Are we OK coupling this crate to the http crate?
There was a problem hiding this comment.
I have the same worry, but http crate is an industry standard and we need to consider it everywhere anyway. I don't think we can avoid interfacing with it.
There was a problem hiding this comment.
I'd rather we introduce our own types that mirror these, and include crate features to make it easier to interop with the http crate's URI type and the stand-alone url crate. So we still play nice, but it's a separate feature.
There was a problem hiding this comment.
I'd certainly like that, although the amount of work behind that to make it work well is quite non-trivial. It would be possible to start by newtype wrapping http and forwarding API to it, but I'd prefer to not do that and switch to our own types as a future breaking change that fully replaces it instead.
The reason is that there is some weirdness in http behavior which they can't get rid of anymore for backwards compatibility reasons. We will be able to drop that compatibility when we switch types, but if we wrap those types now, I'm afraid that we will conserve the behavior.
Would it be ok to introduce this as a breaking change in future major version instead of now as a part of open sourcing?
| invalid_char: c, | ||
| position: i, | ||
| }); | ||
| pub fn new_raw(raw: impl Into<String>) -> Result<Self, UriSafeError> { |
There was a problem hiding this comment.
When should someone use this instead of new above? Should this an unsafe function? Maybe new_unchecked would be more idiomatic?
There was a problem hiding this comment.
I can imagine using this the moment you already have an urlencoded string, which can happen. New new() would reencode % symbols and mess up the url.
I don't like unchecked explicitly checks though, the old new is now infallible due to inclusion of url encoding.
Maybe
new -> new_encode or just encode
new_raw -> new
?
Although the reason I went for new is that I'd like it to be a prioritized way to construct this.
Honestly, urlencoding is a mess. I hate that you can't safely do a second encoding pass on an already encoded string.
No description provided.