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

[IFT] switch to uri_template_system crate for URI template expansion. #1299

Merged
merged 2 commits into from
Jan 7, 2025

Conversation

garretrieger
Copy link
Contributor

The uri-template crate panics when encountering errors so switch to the uri-template-system crate which has error handling built into the API. Fixes fuzzer crashes from #1280.

The uri-template crate panics when encountering errors so switch to the uri-template-system crate which has error handling built into the API. Fixes fuzzer crashes from #1280.
Copy link
Member

@cmyr cmyr left a comment

Choose a reason for hiding this comment

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

overall makes sense but I have some questions about the API...

@@ -153,7 +153,8 @@ impl PatchGroup<'_> {
partial_invalidation_iftx,
mut no_invalidation_ift,
mut no_invalidation_iftx,
} = GroupingByInvalidation::group_patches(candidates, ift_compat_id, iftx_compat_id);
} = GroupingByInvalidation::group_patches(candidates, ift_compat_id, iftx_compat_id)
.map_err(|_| ReadError::MalformedData("Malformed URI templates."))?;
Copy link
Member

Choose a reason for hiding this comment

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

we have an inner error here that should provide more detail, why not preserve that in a BadUri error variant?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure I want to add a ReadError type that's specific to IFT since ReadError is more general than IFT. MalformedData does capture the essence of the error and in this case the inner type doesn't have any additional information that the error string doesn't already capture.

@drott
Copy link
Contributor

drott commented Jan 7, 2025

In relation to your earlier comment on the issue? Do we benefit a lot from the dependency? What is the main functionality we use and could we do without the dependency, what's the tradeoff?

Copy link
Member

@cmyr cmyr left a comment

Choose a reason for hiding this comment

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

I'm satisfied, although there's an outstanding Q from dominik.

@garretrieger
Copy link
Contributor Author

In relation to your earlier comment on the issue? Do we benefit a lot from the dependency? What is the main functionality we use and could we do without the dependency, what's the tradeoff?

This dep is an implementation of https://datatracker.ietf.org/doc/html/rfc6570 which is needed for the IFT mechanism. Writing our own would be a sizable task so I decided to stick with an existing crate in order to get this fuzzer issue sorted out in a timely fashion. I haven't ruled out replacing it with our own at some future point if we're looking to trim off dependencies.

@drott
Copy link
Contributor

drott commented Jan 7, 2025

This dep is an implementation of https://datatracker.ietf.org/doc/html/rfc6570 which is needed for the IFT mechanism. Writing our own would be a sizable task so I decided to stick with an existing crate in order to get this fuzzer issue sorted out in a timely fashion.

Thanks for the clarifications. Which parts, as in: replacement rule/format, of the RFC are we using and expecting to use in the future? Is the IFT spec allowing multiple types of replacements, or only few of them?

Ok with me to land this for now, but I would like to understand if we can strip a dependency.

@garretrieger
Copy link
Contributor Author

garretrieger commented Jan 7, 2025

This dep is an implementation of https://datatracker.ietf.org/doc/html/rfc6570 which is needed for the IFT mechanism. Writing our own would be a sizable task so I decided to stick with an existing crate in order to get this fuzzer issue sorted out in a timely fashion.

Thanks for the clarifications. Which parts, as in: replacement rule/format, of the RFC are we using and expecting to use in the future? Is the IFT spec allowing multiple types of replacements, or only few of them?

Ok with me to land this for now, but I would like to understand if we can strip a dependency.

We are using nearly the entirety of that spec. Specifically in the IFT client we do expansion of templates utilizing the syntax from the RFC and as the IFT spec is currently written all four operator levels are supported. The only part we're not using is expansion of composite values. For reference here's the relevant section from IFT.

@garretrieger garretrieger merged commit ed371e7 into main Jan 7, 2025
10 checks passed
@garretrieger garretrieger deleted the uri_templates branch January 7, 2025 17:56
@drott
Copy link
Contributor

drott commented Jan 8, 2025

We are using nearly the entirety of that spec. Specifically in the IFT client we do expansion of templates utilizing the syntax from the RFC and as the IFT spec is currently written all four operator levels are supported. The only part we're not using is expansion of composite values. For reference here's the relevant section from IFT.

Makes sense, thanks.

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 this pull request may close these issues.

3 participants