TypeError: unhashable type: 'dict'

Hello,
First time user of Indico, trying to set up a test instance for our College. I just ran into an issue where we are getting an error trying to upload files to an event or lecture. The error is : TypeError: unhashable type: ‘dict’. Searching I could find this issue anywhere. I have full traceback but being new user, the form will not let me post it here.

posting it in a code block doesn’t work?

```
paste it here
```

anyway, I lifted the new-user restrictions from your account. But I still think they only affect uploads, not text posts - and a traceback is much better as text :wink:

When I tried to paste in the error stack it said I wasn’t allowd more than two links in a post. Another try below with out the links in the error stack removed the https part.

Traceback (most recent call last):
  File "/opt/indico/.venv/lib/python2.7/site-packages/flask/app.py", line 1949, in full_dispatch_request
    rv = self.dispatch_request()
  File "/opt/indico/.venv/lib/python2.7/site-packages/flask/app.py", line 1935, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/opt/indico/.venv/lib/python2.7/site-packages/indico/modules/attachments/blueprint.py", line 47, in view_func
    return categ_view(**kwargs) if kwargs['object_type'] == 'category' else event_view(**kwargs)
  File "/opt/indico/.venv/lib/python2.7/site-packages/indico/web/flask/util.py", line 84, in wrapper
    return obj().process()
  File "/opt/indico/.venv/lib/python2.7/site-packages/indico/web/rh.py", line 275, in process
    res = self._do_process()
  File "/opt/indico/.venv/lib/python2.7/site-packages/indico/web/rh.py", line 245, in _do_process
    rv = self._process()
  File "/opt/indico/.venv/lib/python2.7/site-packages/indico/modules/attachments/controllers/management/base.py", line 94, in _process
    attachment.file.save(f.stream)
  File "/opt/indico/.venv/lib/python2.7/site-packages/indico/core/storage/models.py", line 198, in save
    self.storage_file_id, self.md5 = self.storage.save(path, self.content_type, self.filename, data)
  File "/opt/indico/.venv/lib/python2.7/site-packages/indico/core/storage/models.py", line 171, in storage
    return get_storage(self.storage_backend)
  File "/opt/indico/.venv/lib/python2.7/site-packages/indico/core/storage/backend.py", line 38, in get_storage
    definition = config.STORAGE_BACKENDS[backend_name]
TypeError: unhashable type: 'dict'

Oh I see, you had pasted the full error report email which contains URLs as well. I removed all but the traceback from your post since that’s the only relevant part here.

It sounds like your ATTACHMENT_STORAGE is set to a dict instead of a string in indico.conf.

Thank you. Here is the indico.conf general settings I have. The storage is set to default it looks like. What should be the setting?

# General settings
SQLALCHEMY_DATABASE_URI = 'postgresql:///indico'
SECRET_KEY = '<secret>'
BASE_URL = 'https://indico.science.oregonstate.edu'
CELERY_BROKER = 'redis://127.0.0.1:6379/0'
REDIS_CACHE_URL = 'redis://127.0.0.1:6379/1'
CACHE_BACKEND = 'redis'
DEFAULT_TIMEZONE = 'America/Los_Angeles'
DEFAULT_LOCALE = 'en_GB'
ENABLE_ROOMBOOKING = True
CACHE_DIR = '/opt/indico/cache'
TEMP_DIR = '/opt/indico/tmp'
LOG_DIR = '/opt/indico/log'
STORAGE_BACKENDS = {'default': 'fs:/indico/storage/archive'}
ATTACHMENT_STORAGE = {'default': 'fs:/indico/storage/attachments'}
XELATEX_PATH = '/opt/texlive/bin/x86_64-linux/xelatex'
PLUGINS = {'importer', 'importer_invenio', 'livesync', 'piwik', 'previewer_jupyter', 'vc_vidyo'}

You need to change the SECRET_KEY right now since you just exposed it to the public. Just put a new gibberish string in there.

And the problem is what I expected. You need this: ATTACHMENT_STORAGE = 'default'

Reload/restart uWSGI and celery afterwards.

I did modify the secret key. That ATTACHMENT_STORAGE is already set to ‘default’. Isn’t the second part on that line specifying where to store the uploaded documents?

Looks to work as you stated. However, how do you change the location where files are uploaded in the indico.conf file?

Scratch that. It let me upload files now. But when you click on the uploaded file getting this error:

# Not Found

The requested URL /event/22/attachments/4/12/download.pdf was not found on this server.
2020-06-04 08:42:40,198  0000000000000000  indico.plugin.piwik - ERROR piwik.py:71 -- Unable to connect

Traceback (most recent call last):
  File "/opt/indico/.venv/lib/python2.7/site-packages/indico_piwik/piwik.py", line 66, in _perform_call
    response = requests.get(query_url, timeout=timeout)
  File "/opt/indico/.venv/lib/python2.7/site-packages/requests/api.py", line 76, in get
    return request('get', url, params=params, **kwargs)
  File "/opt/indico/.venv/lib/python2.7/site-packages/requests/api.py", line 61, in request
    return session.request(method=method, url=url, **kwargs)
  File "/opt/indico/.venv/lib/python2.7/site-packages/requests/sessions.py", line 530, in request
    resp = self.send(prep, **send_kwargs)
  File "/opt/indico/.venv/lib/python2.7/site-packages/requests/sessions.py", line 643, in send
    r = adapter.send(request, **kwargs)
  File "/opt/indico/.venv/lib/python2.7/site-packages/requests/adapters.py", line 514, in send
    raise SSLError(e, request=request)

SSLError: HTTPSConnectionPool(host='127.0.0.1', port=443): Max retries exceeded with url: /piwik/piwik.php?idSite=2&url=https%3A//indico.science.oregonstate.edu/event/22/attachments/4/12/download.pdf&h=8&m=42&action_name=Download%20-%20download.pdf&s=40&idsite=2&token_auth=&download=https%3A//indico.science.oregonstate.edu/event/22/attachments/4/12/download.pdf&rec=1 (Caused by SSLError(SSLError(1, u'[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:618)'),))

ATTACHMENT_STORAGE only tells Indico which storage backend you would like to use to store any new attachments. That backend still needs to be defined in STORAGE_BACKENDS.

As for the error you’re seeing, it looks like you have enabled the Piwik plugin but are pointing to a Piwik server with an expired/invalid certificate (localhost, makes sense). Disabling the plugin or fixing the certificate should work.

I have the piwik plugin removed and restarted all services. Unfortunately still getting the 404 error but now no error stack coming in either.

Here is the plugins line in the conf file:

PLUGINS = {'importer', 'importer_invenio', 'livesync', 'previewer_jupyter', 'vc_vidyo'}

Do you get anything in your indico.log?

Only this:

2020-06-04 09:10:31,801  INFO     52a870d6f5b14d04  indico.rh                 GET /category/4/attachments/6/15/download.pdf [IP=10.206.30.12] [PID=16504] [UID=1]
# Not Found

The requested URL /category/4/attachments/6/15/download.pdf was not found on this server.

I believe the file was loaded here on the server:
./storage/category/4/15-11-download.pdf

Stupid question, but are you sure the file exists? Have you changed the storage config at some point? Can you find the file in /indico/storage/archive ?

I did change the storage location to point to a larger disk volume on the server, I believe this is the line in the conf file correct?

STORAGE_BACKENDS = {'default': 'fs:/indico/storage/archive'}

The file is being stored as: /indico/storage/archive/category/4/16-12-download.pdf

The URL being generated is this however:
https://indico.science.oregonstate.edu/category/4/attachments/6/16/download.pdf

Check your webserver’s error log (/opt/indico/log/nginx/error.log or /opt/indico/log/apache/error.log). Maybe there’s some problem serving the files from your non-standard location. Even though I’d expect a 403 error in that case.

PS: When posting tracebacks, configs, etc. please put them between fences of triple-backticks, like this. That way they are formatted in a readable way:

```
paste stuff
here
```

PPS: Are you sure you need/want these plugins? 'importer', 'importer_invenio', 'livesync'
The first two are rarely used (and useless unless you have an invenio instance - possibly an old one since I don’t think anyone tested it with recent invenioo versions), and the last one is useless on its own, and right now there are no livesync backends available out there that are particularly useful for others.

Thank you. Here is the error from apache:

[Thu Jun 04 13:27:02.571391 2020] [:error] [pid 3594] (20023)The given path was above the root path: [client 10.206.30.12:63331] xsendfile: unable to find file: /indico/storage/archive/category/4/20-16-TDA2422.pdf, referer: https://indico.science.oregonstate.edu/category/4/

I went ahead and removed the plugins ‘importer’, ‘importer_invenio’, ‘livesync’.

There we go…

Add this below XSendFilePath /opt/indico in your Apache config:

XSendFilePath /indico/storage

Awesome! That did it.