How to fix the MultipleObjectsReturned error in Hue

Published on 14 March 2014 in Development - 1 minute read - Last modified on 19 April 2021

When going on the Home page (/home) in Hue 3.0, this error could appear:

MultipleObjectsReturned: get() returned more than one DocumentPermission - it returned 2! Lookup parameters were {'perms': 'read', 'doc': <Document: saved query Sample: Job loss sample>}

This is fixed in Hue 3.6 and here is a way to repair it:

  1. Backup the Hue database.

  2. Run the cleanup script:

    from desktop.models import DocumentPermission, Document

    for document in Document.objects.all(): try: perm, created = DocumentPermission.objects.get_or_create(doc=document, perms=DocumentPermission.READ_PERM) except DocumentPermission.MultipleObjectsReturned: # We can delete duplicate perms of a document dups = DocumentPermission.objects.filter(doc=document, perms=DocumentPermission.READ_PERM) perm = dups[0] for dup in dups[1:]: print(‘Deleting duplicate %s’ % dup) dup.delete()


comments powered by Disqus

More recent stories

26 June 2024
Integrating Trino Editor in Hue: Supporting Data Mesh and SQL Federation
Read More
03 May 2023
Discover the power of Apache Ozone using the Hue File Browser
Read More