Skip to content

Alternative to constrained long paths in URLs: nano-id / uuid #593

Closed as not planned

Description

@joepio

URL's are:

  • always resolvable
  • always unique
  • often meaningful. But not always.

We often convey structure using URLs. In #556 , I introduced a way to make sure that the parent is present in the URL. This is useful, but can also lead to very long URLs for large content.

We could also allow new resources creates at /uuid or /nanoid as long as their path conforms to one of these specs.

With these random character IDs, we're sure that they are not meaningful, which means that users cant accidentally derive wrong information about them, or depend on their paths.

But I wonder - can we validate these ids so they are in fact random strings of characters? They will be created on the client.

In the case of NanoID, I don't think that's possible. That means evil-string999 is a valid nanoid.

UUID contains a dates encoded in it, so it always looks random.

are there other options?

Consideration

  • This means that we can't find the parent resource by looking at the path. This has major implications for how fast we can resolve things / check rights.

Activity

  1. kod-kristoff commented on Mar 9, 2023

    @kod-kristoff

    If you require uniqueness, you must anyway check for that, since neither nanoid or uuid is guarenteed to be unique, only very unlikely, so given enough time and users with different PRNGs, you will get a collision.

    Another option that I used is:
    ulid are quite nice, lexicographical sortable and compact representation.

    At least two implementations in rust:

  2. joepio commented on Mar 9, 2023

    @joepio
    MemberAuthor

    Thanks @kod-kristoff, ulid sounds like a good alertenative!

    And the uniqueness will always be enforced by the server (currently also by the client, but I think that is not worth it for 1 in a trillion checks failing)

  3. AlexMikhalev commented on Jan 19, 2024

    @AlexMikhalev
    Contributor

    ULID allows sharding on different partitions in the store, which supports it, i.e. lexicographically sortable translates that ULIDS will be next to each other when partitioned using standard hashing algorithms.

  4. added 2 commits that reference this issue on Apr 22, 2024
  5. added a commit that references this issue on Apr 24, 2024
  6. added a commit that references this issue on Jun 16, 2026
  7. joepio commented on Sep 12, 2026

    @joepio
    MemberAuthor

    Closing as consolidated into #1139 during the requested backlog cleanup. The remaining requirements from this issue are preserved in a new comment on #1139. This is not a claim that every requested behavior is implemented; please continue current work in that tracker. The issue and discussion remain available for reference.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions