fedora-infra / anitya

A cross-distribution upstream release monitoring project
https://release-monitoring.org
GNU General Public License v2.0
237 stars 104 forks source link

enable deleting distro mapping with slash in package name #1772

Closed arthurzam closed 2 months ago

arthurzam commented 2 months ago

Since we at gentoo plan to start add a lot of mapping for gentoo packages, I'm making sure everything works well with our naming scheme. In gentoo, every package is behind a category, for example dev-lang/python. As stated in https://github.com/fedora-infra/anitya/issues/965, this results in inability to easily delete the mapping. The only existing workaround to do it is to edit it, put another "simple" value, and only then delete.

So why does it happen? The flask URL for that expected a single path item, but because of this value, we get 2. So by using path: flask annotation, we teach it expect at least one path item, but also multiple. I've tested it by booting a local dev instance, loading from dump, and making myself an admin in postgres, after which I started to play and verify it started to work again. I've also added a test for that thing, since I do agree this might be weird in code, so better test expected behavior.

Sadly this solution isn't enough for cases where the mapping starts or ends with a slash. In this case the browser automatically sanitizes and removes "duplicate" slash in path. But workaround I gave above still works.

softwarefactory-project-zuul[bot] commented 2 months ago

Build succeeded. https://fedora.softwarefactory-project.io/zuul/buildset/201a52ed9df24dc2bb7a76df1d04be8e

:heavy_check_mark: fi-tox-mypy SUCCESS in 5m 05s :heavy_check_mark: fi-tox-lint SUCCESS in 5m 10s :heavy_check_mark: fi-tox-format SUCCESS in 4m 49s :heavy_check_mark: fi-tox-python38 SUCCESS in 9m 09s :heavy_check_mark: fi-tox-python39 SUCCESS in 8m 41s :heavy_check_mark: fi-tox-python310 SUCCESS in 9m 22s :heavy_check_mark: fi-tox-python311 SUCCESS in 9m 18s :heavy_check_mark: fi-tox-docs SUCCESS in 6m 06s :heavy_check_mark: fi-tox-bandit SUCCESS in 5m 07s :heavy_check_mark: fi-tox-diff-cover SUCCESS in 9m 28s

Zlopez commented 2 months ago

Thanks for the contribution, this is a nice solution to the problem.

softwarefactory-project-zuul[bot] commented 2 months ago

Build succeeded. https://fedora.softwarefactory-project.io/zuul/buildset/d53f9e5f57e5451bb39a2fdf3b81b7cd

:heavy_check_mark: fi-tox-mypy SUCCESS in 5m 04s :heavy_check_mark: fi-tox-lint SUCCESS in 4m 50s :heavy_check_mark: fi-tox-format SUCCESS in 4m 49s :heavy_check_mark: fi-tox-python38 SUCCESS in 9m 13s :heavy_check_mark: fi-tox-python39 SUCCESS in 9m 00s :heavy_check_mark: fi-tox-python310 SUCCESS in 9m 09s :heavy_check_mark: fi-tox-python311 SUCCESS in 8m 55s :heavy_check_mark: fi-tox-docs SUCCESS in 6m 27s :heavy_check_mark: fi-tox-bandit SUCCESS in 4m 51s :heavy_check_mark: fi-tox-diff-cover SUCCESS in 9m 32s