diff --git a/lib/galaxy/webapps/galaxy/controllers/history.py b/lib/galaxy/webapps/galaxy/controllers/history.py index e4746fb6cba0..fd3f1a036f20 100644 --- a/lib/galaxy/webapps/galaxy/controllers/history.py +++ b/lib/galaxy/webapps/galaxy/controllers/history.py @@ -97,7 +97,13 @@ def display_by_username_and_slug(self, trans, username, slug, **kwargs): session = trans.sa_session user = session.scalars(select(model.User).filter_by(username=username).limit(1)).first() - history = session.scalars(select(model.History).filter_by(user=user, slug=slug, deleted=False).limit(1)).first() + history = session.scalars( + select(model.History) + .filter_by(user=user, slug=slug, deleted=False) + # return public histories first if slug is not unique + .order_by(model.History.importable.desc()) + .limit(1) + ).first() if history is None: raise web.httpexceptions.HTTPNotFound()