Skip to content

uuidgen: accept a UUID as --namespace - #674

Open
jayhemnani9910 wants to merge 2 commits into
uutils:mainfrom
jayhemnani9910:uuidgen-uuid-namespace
Open

jayhemnani9910 wants to merge 2 commits into
uutils:mainfrom
jayhemnani9910:uuidgen-uuid-namespace

Conversation

@jayhemnani9910

Copy link
Copy Markdown
Contributor

uuidgen --namespace only takes the four @dns, @url, @oid and @x500 names. util-linux also takes any UUID there, which is how name-based UUIDs under an application's own namespace are made:

$ uuidgen -m -n 6ba7b810-9dad-11d1-80b4-00c04fd430c8 -N a
util-linux 2.41.3: 4c104dd0-4821-30d5-9ce3-0e7a1f8b7c0d
uutils:            error: invalid value '6ba7b810-9dad-11d1-80b4-00c04fd430c8' for '--namespace <namespace>': Invalid namespace 6ba7b810-9dad-11d1-80b4-00c04fd430c8.

namespace_from_str now falls back to parsing a UUID. Like libuuid's uuid_parse(), only the 36-character hyphenated form is accepted, in either case; braced, urn:uuid: and 32-digit forms are still rejected, as util-linux rejects them. The help text mentions it.

New test test_uuid_namespace (fails without the change) checks a lower and an upper case UUID against util-linux's output and the four rejected forms. The uuidgen tests pass (9), cargo clippy --all-targets -D warnings is clean for the crate. The two UUIDs also match Python's uuid.uuid3/uuid.uuid5.

Copilot AI balanced review requested due to automatic review settings October 23, 2026 06:11

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

Comment thread tests/by-util/test_uuidgen.rs Outdated
new_ucmd!()
.args(&["-s", "-n", namespace, "-N", "a"])
.fails()
.code_is(1);

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.

could you please also check the error message here? the exit code alone could come from something else :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done in bcd5dfc: each rejected namespace now also checks for Invalid namespace <value>. on stderr.

Copilot AI balanced review requested due to automatic review settings October 25, 2026 07:40

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

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