Skip to content

Make fluent-uri an optional dependency with feature flag#863

Open
woodruffw-bot wants to merge 1 commit into
CycloneDX:mainfrom
woodruffw-bot:claude/optional-dependencies-update-BzL5o
Open

Make fluent-uri an optional dependency with feature flag#863
woodruffw-bot wants to merge 1 commit into
CycloneDX:mainfrom
woodruffw-bot:claude/optional-dependencies-update-BzL5o

Conversation

@woodruffw-bot

@woodruffw-bot woodruffw-bot commented Mar 30, 2026

Copy link
Copy Markdown

Hello cyclonedx-bom maintainers!

I'm opening this up as part of my work on astral-sh/uv#18761 -- we noticed some dependency shiftage with that PR, which led me to observing that we (as the downstream) don't actually need the fluent-uri dependency at all (it's only used for validation, and we already pre-validate all of our URLs).

Consequently, this makes fluent-uri an optional dep. To avoid breakage I've retained it as a default feature, but this could be changed to make it opt-in in a subsequent release (your call!)

Disclosure: the changes in this PR were performed by Claude, through my own orchestration. I've manually reviewed them for correctness/expected behavior.

This allows downstream users to disable the `fluent-uri` feature to
remove the dependency when URI validation is not needed.

https://claude.ai/code/session_01H51ccpYf6jhtzujzWiypPc
Signed-off-by: woodruffw-bot <william+ai@yossarian.net>
@woodruffw-bot woodruffw-bot force-pushed the claude/optional-dependencies-update-BzL5o branch from e02eb2e to 2b8cb98 Compare March 30, 2026 16:00
@woodruffw-bot woodruffw-bot marked this pull request as ready for review March 30, 2026 16:04
@woodruffw-bot woodruffw-bot requested a review from a team as a code owner March 30, 2026 16:04

@lfrancke lfrancke left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you explain again what your motivation for this is? You'd just like to get rid of dependencies, right?

In general I'm fine with that - I'm just not super happy with the implementaiton/documentation of it.

We also have a test invalid_uris_should_fail_validation which will fail when built without the feature now. I have to admit: I didn't test it yet. I only looked at this PR in Github right now.

pub fn validate_uri(uri: &Uri) -> Result<(), ValidationError> {
if Url::parse(uri.0.as_str()).is_err() {
pub fn validate_uri(_uri: &Uri) -> Result<(), ValidationError> {
#[cfg(feature = "fluent-uri")]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

My main concern is - if I understand it correctly - that validate_uri just silently skips validation when the feature is off. I am not sure I like that.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Maybe a better option here would be to condition validate_url out entirely, i.e. only include that API if fluent-uri (or whatever we end up naming the feature) is actually enabled, which it will be by default. Would that address your concern?

(The outcome of that is that it would become structurally impossible to call validate_uri as a no-op, since it wouldn't be present when the feature is disabled.)

Comment thread cyclonedx-bom/Cargo.toml

[features]
default = ["fluent-uri"]
fluent-uri = ["dep:fluent-uri"]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I honestly have no idea what best-practice is in the Rust world. This seems pretty...specific. Maybe a name like "uri-validation" might be better for this feature? And maybe it should just remove the entire function then and anything that calls it to give no false sense of security?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Unfortunately, I'd say there's no really consistent idiom for feature naming in Rust -- some people prefer to give it the exact name of the dep, others prefer a descriptive name (like uri-validation). I'm happy to do whichever one you prefer!

(I see you reached the same idea about removing the entire function here, I'll go ahead with that.)

@woodruffw

Copy link
Copy Markdown

Can you explain again what your motivation for this is? You'd just like to get rid of dependencies, right?

Yes, that's the idea. There are downstream applications (like those in uv) where all URLs are pre-validated, so having an additional validation layer on the CycloneDX side gains us nothing (and adds to our dependency stack/final binary size). We'd love to remove those redundancies, if possible.

We also have a test invalid_uris_should_fail_validation which will fail when built without the feature now. I have to admit: I didn't test it yet. I only looked at this PR in Github right now.

Oh, thanks for catching that. I'll tweak so that test is only compiled when the proper feature is also activated.

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