Skip to content

Check uuid shape through one helper; python_script's Uuid::parse_str also accepts braced, urn and unhyphenated forms #1845

Closed as duplicate

Description

[agent] Filed by the scheduled architecture audit (audit-core). Register: register.

Kind: refactor. Register ID: A15.

Problem

"Is this segment a uuid" is answered four ways in core:

The last one has drifted. Uuid::parse_str also accepts the 32-hex simple form, {braced} and urn:uuid: forms. So a hosted-URL grant segment that every other recognizer (hosted_patch_url_uuids uses is_canonical_uuid) rejects is accepted there as a uuid.

The CLI also re-tests the core rule with 14 looks_like_uuid_* tests (crates/socket-patch-cli/src/lib.rs L475-L562).

Proposed change

  • Keep two named rules in one place, patch::path_safety: is_canonical_uuid (path segments the server mints) and is_uuid_shaped (user input, any case).
  • Delete redact's private copy.
  • Replace the three Uuid::parse_str(..).is_ok() calls with is_canonical_uuid.
  • Re-export or move target::is_uuid_shaped there.

Size

4 files in core (plus the import in the CLI). About −30 lines.

Acceptance criteria

  • Existing target, redact, path_safety and python_script tests pass.
  • Add one same_hosted_artifact test where a braced or unhyphenated uuid grant segment is not treated as a rotation.
  • Drop the CLI's duplicated looks_like_uuid_* tests, or keep a single smoke test.

Activity

  1. added
    arch-auditFiled by a scheduled architecture audit routine (see the architecture review discussion)
    refactorStructural change: duplicated code or logic, missing abstraction, layering, dead code
    on Oct 29, 2026
  2. mikolalysenko commented on Oct 29, 2026

    @mikolalysenko
    CollaboratorAuthor

    [agent] Triaged: priority:p3 (cross-cutting refactor). Related to the older tracking issue #705 (one utils::uuid grammar). This is one concrete instance of it, not a duplicate.


    Generated by Claude Code

  3. mikolalysenko commented on Oct 30, 2026

    @mikolalysenko
    CollaboratorAuthor

    [agent] Janitor: closing as a duplicate of #705, the older tracking issue for one UUID grammar in core. Both ask for the same change: one named rule (canonical lowercase for server-minted path segments, any case for user input), with the Uuid::parse_str grant checks in python_script.rs replaced by it.

    Site list on origin/main 5ca56238, carried over for #705 (several of #705's original sites are gone):

    • utils::target::is_uuid_shaped, crates/socket-patch-core/src/utils/target.rs:329
    • a private twin, utils::redact::is_uuid_shaped, crates/socket-patch-core/src/utils/redact.rs:79
    • patch::path_safety::is_canonical_uuid, crates/socket-patch-core/src/patch/path_safety.rs:51
    • uuid::Uuid::parse_str ×3 in python_script::same_hosted_artifact, crates/socket-patch-core/src/utils/python_script.rs:99-101. These accept simple, braced and urn:uuid: forms that hosted_patch_url_uuids rejects.
    • 14 looks_like_uuid_* tests in crates/socket-patch-cli/src/lib.rs:480-562

    Extra acceptance item from here: a same_hosted_artifact test where a braced or unhyphenated grant segment isn't treated as a rotation. Reopen if you want the two tracked separately.


    Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent:triagedarch-auditFiled by a scheduled architecture audit routine (see the architecture review discussion)duplicateThis issue or pull request already existspriority:p3refactorStructural change: duplicated code or logic, missing abstraction, layering, dead code

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions