Files
ubicloud/spec/ubid_spec.rb
Enes Cakir 8eb223790a Raise a parse error for all types of invalid UBID
If the UBID is not 26 characters long, we raise a UBIDParseError
exception. In `Model.from_ubid`, if the UBIDParseError exception is
raised, we catch it and return nil since the resource does not exist.

However, a UBID can be 26 characters long but still not valid. For
example, "vm164pbm96-a3grq6vbsvjb3ax" has 26 characters, but because of
the "-", it's not a valid UBID. When an invalid UBID with 26 characters
is passed to the URL, it raises an "Invalid base32 encoding" error and
returns an HTTP 500 exception which happens in production time to time.
Instead, we should return HTTP 404 since the resource with the given ID
does not exist. We return 404 if the UBID doesn't have 26 characters.
2025-02-20 09:57:53 +03:00

16 KiB