kamaln7/klein

b.Config.Storage.Get() for BoltDB does not return error if url is not found

Closed this issue · 2 comments

It seems that
*func (p Provider) Get(alias string) (string, error)
in storage/bolt/main.go
does not return an error if the url is not found in the boltdb.

The function just returns an empty url which results in always redirecting to the main page or a different page if root-redirect is enabled instead of resulting in a 404.

Possible fix would be to check the url:
if url == nil { return "", storage.ErrNotFound }

Thanks for reporting this @osalzgeber. I'll fix this once I have some more time to work on klein 👍

@osalzgeber this is now fixed & released on version v3.0.1: https://github.com/kamaln7/klein/releases/tag/v3.0.1

Please see the upgrade notes for version 3.0.0, you will need to make a small change to the config file to upgrade from versions 2.*: https://github.com/kamaln7/klein/releases/tag/v3.0.0