parabuzzle / craneoperator

Gives you a simple web interface for browsing around a Docker Registry
https://hub.docker.com/r/parabuzzle/craneoperator
MIT License
127 stars 32 forks source link

Malformed version number string raised in sort_versions #22

Closed slillibri closed 7 years ago

slillibri commented 7 years ago

I have a container with tags

["latest", "test-stash-68ec25", "test-stash-862ece"]

which causes the sort_versions function to raise

16:08:09 web.1  | 2017-04-21 16:08:09 - ArgumentError - Malformed version number string -stash-68ec25:
16:08:09 web.1  |       /usr/local/lib/ruby/site_ruby/2.3.0/rubygems/version.rb:207:in `initialize'
16:08:09 web.1  |       /usr/local/lib/ruby/site_ruby/2.3.0/rubygems/version.rb:199:in `new'
16:08:09 web.1  |       /usr/local/lib/ruby/site_ruby/2.3.0/rubygems/version.rb:199:in `new'
16:08:09 web.1  |       /server.rb:81:in `block in sort_versions'
16:08:09 web.1  |       /server.rb:81:in `each'
16:08:09 web.1  |       /server.rb:81:in `sort_by'
16:08:09 web.1  |       /server.rb:81:in `sort_versions'
16:08:09 web.1  |       /server.rb:111:in `container_tags'

Removing the call to sort_versions from container_tags fixed this for me.

parabuzzle commented 7 years ago

yea, that method is super fragile (only supports semantic versioned tags). I need to make it a bit more resilient to tags that aren't semver based.

Thanks for the bug report @slillibri, I'll see if I can find some time to fix that for you this week. (or you could send a Pull Request 😉 )

elsmorian commented 7 years ago

Hi, just to say I am also hitting this with tags named "2016.09_02", I tried to have a look if I could submit a Pull Request but I have no Ruby experience and doesn't look super easy having a quick glance of the sort_versions method.

However, might be only a small change, at least in my case - I guess it would be to restrict the valid_version_numbers regex to only match the semantic versioning you are talking about, and then append a naturally sorted version of whatever other tags are there - we chose ours intact so a natural sort would do the right thing, and from a quick Python trial I would guess Ruby would too :)

>>> versions = ["2017.02_07", "2016.01_03", "2016.10_02", "2017.01_14"]
>>> versions.sort()
>>> versions
['2016.01_03', '2016.10_02', '2017.01_14', '2017.02_07']
parabuzzle commented 7 years ago

@elsmorian can you check with parabuzzle/craneoperator:2.1.5 and see if this is working now?

elsmorian commented 7 years ago

I can confirm I no longer hit this and the UI loads and populates fine, thanks very much for the update!

Our tags (as described above) are not being sorted, would be super handy to have even the non-semantic tags attempt to be sorted!

elsmorian commented 7 years ago

I have attempted https://github.com/parabuzzle/craneoperator/pull/34 which might help!?

parabuzzle commented 7 years ago

fixed in 2.1.8.