Skip to content

ArgumentError: invalid range "r-0" in string transliteration #77

Open
@askehansen

Description

@askehansen

I ran into this rare issue where I have a model PlaylistTrack and when I call find(id) it throws this error: ArgumentError: invalid range "r-0" in string transliteration.

The error is thrown from the hashids gem with @guards being "r-0" https://github.com/peterhellberg/hashids.rb/blob/b729fe514e492e18d9f69473b53eb59a3b5aee4b/lib/hashids.rb#L117

The issue was resolved after adding an explicit pepper to something else instead of the implicit "playlist_tracks":

class PlaylistTrack < ApplicationRecord
  include Hashid::Rails
  hashid_config pepper: "playlisttracks"
  ...
end

Using this pepper resulted in the @guards being "y7d" instead which is accepted.

I guess its just by chance that "playlist_tracks" produces a problematic pepper but this could potentially be a problem with other table names as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions