Repository: LMFDB/lmfdb

Issue:
Classical modular search producing server error
From the feedback page regarding 

 https://www.lmfdb.org/ModularForm/GL2/Q/holomorphic/?hst=Dimensions&weight_parity=even&level=2&weight=2-40&char_parity=even&level_primes=2&char_order=1&search_type=Dimensions

produces a server error.

Asking for level 2, wt 2-100, bad prime *exactly* 2, the dimension table and form lists come out fine. But then I ask for level 2, wt 2-40, bad prime *include* 2, the list of forms come out fine. But the dimension table causes a server error.
 



Classical modular search producing server error
From the feedback page regarding 

 https://www.lmfdb.org/ModularForm/GL2/Q/holomorphic/?hst=Dimensions&weight_parity=even&level=2&weight=2-40&char_parity=even&level_primes=2&char_order=1&search_type=Dimensions

produces a server error.

Asking for level 2, wt 2-100, bad prime *exactly* 2, the dimension table and form lists come out fine. But then I ask for level 2, wt 2-40, bad prime *include* 2, the list of forms come out fine. But the dimension table causes a server error.
 





Discussion:
Traceback:
```
`Exception on /ModularForm/GL2/Q/holomorphic/ [GET]
Traceback (most recent call last):
  File "/home/sage/sage-9.1/local/lib/python3.7/site-packages/flask/app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/sage/sage-9.1/local/lib/python3.7/site-packages/flask/app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/sage/sage-9.1/local/lib/python3.7/site-packages/flask/app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/home/sage/sage-9.1/local/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/home/sage/sage-9.1/local/lib/python3.7/site-packages/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/sage/sage-9.1/local/lib/python3.7/site-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/home/lmfdb/lmfdb-git-dev/lmfdb/classical_modular_forms/main.py", line 216, in index
    return dimension_form_search(info)
  File "/home/lmfdb/lmfdb-git-dev/lmfdb/utils/search_wrapper.py", line 203, in __call__
    res = self.postprocess(res, info, query)
  File "/home/lmfdb/lmfdb-git-dev/lmfdb/classical_modular_forms/main.py", line 971, in dimension_form_postprocess
    dimension_common_postprocess(info, query, ['S'], ['new'], url_generator, pick_table)
  File "/home/lmfdb/lmfdb-git-dev/lmfdb/classical_modular_forms/main.py", line 890, in dimension_common_postprocess
    set_rows_cols(info, query)
  File "/home/lmfdb/lmfdb-git-dev/lmfdb/classical_modular_forms/main.py", line 870, in set_rows_cols
    if info['prime_quantifier'] in ['subset', 'subsets']: # subsets for backward compat in urls
KeyError: 'prime_quantifier'
[2020-06-19 12:58:04 UTC] 500 error on URL http://beta.lmfdb.org/ModularForm/GL2/Q/holomorphic/?hst=Dimensions&weight_parity=even&level=2&weight=2-40&char_parity=even&level_primes=2&char_order=1&search_type=Dimensions ()`
Traceback:
```
`Exception on /ModularForm/GL2/Q/holomorphic/ [GET]
Traceback (most recent call last):
  File "/home/sage/sage-9.1/local/lib/python3.7/site-packages/flask/app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/sage/sage-9.1/local/lib/python3.7/site-packages/flask/app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/sage/sage-9.1/local/lib/python3.7/site-packages/flask/app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/home/sage/sage-9.1/local/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/home/sage/sage-9.1/local/lib/python3.7/site-packages/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/sage/sage-9.1/local/lib/python3.7/site-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/home/lmfdb/lmfdb-git-dev/lmfdb/classical_modular_forms/main.py", line 216, in index
    return dimension_form_search(info)
  File "/home/lmfdb/lmfdb-git-dev/lmfdb/utils/search_wrapper.py", line 203, in __call__
    res = self.postprocess(res, info, query)
  File "/home/lmfdb/lmfdb-git-dev/lmfdb/classical_modular_forms/main.py", line 971, in dimension_form_postprocess
    dimension_common_postprocess(info, query, ['S'], ['new'], url_generator, pick_table)
  File "/home/lmfdb/lmfdb-git-dev/lmfdb/classical_modular_forms/main.py", line 890, in dimension_common_postprocess
    set_rows_cols(info, query)
  File "/home/lmfdb/lmfdb-git-dev/lmfdb/classical_modular_forms/main.py", line 870, in set_rows_cols
    if info['prime_quantifier'] in ['subset', 'subsets']: # subsets for backward compat in urls
KeyError: 'prime_quantifier'
[2020-06-19 12:58:04 UTC] 500 error on URL http://beta.lmfdb.org/ModularForm/GL2/Q/holomorphic/?hst=Dimensions&weight_parity=even&level=2&weight=2-40&char_parity=even&level_primes=2&char_order=1&search_type=Dimensions ()`

Resolving patch:
diff --git a/lmfdb/classical_modular_forms/main.py b/lmfdb/classical_modular_forms/main.py
--- a/lmfdb/classical_modular_forms/main.py
+++ b/lmfdb/classical_modular_forms/main.py
@@ -867,13 +867,13 @@ def set_rows_cols(info, query):
         if primes:
             try:
                 rad = prod(ZZ(p) for p in primes.split(','))
-                if info['prime_quantifier'] in ['subset', 'subsets']: # subsets for backward compat in urls
+                if info.get('prime_quantifier') in ['subset', 'subsets']: # subsets for backward compat in urls
                     info['level_list'] = [N for N in info['level_list'] if (rad % ZZ(N).radical()) == 0]
-                elif info['prime_quantifier'] in ['supset', 'append']: # append for backward compat in urls
+                elif info.get('prime_quantifier') in ['supset', 'append']: # append for backward compat in urls
                     info['level_list'] = [N for N in info['level_list'] if (N % rad) == 0]
-                elif info['prime_quantifier'] in ['complement']:
+                elif info.get('prime_quantifier') in ['complement']:
                     info['level_list'] = [N for N in info['level_list'] if gcd(N,rad) == 1]
-                elif info['prime_quantifier'] in ['exact']:
+                elif info.get('prime_quantifier') in ['exact']:
                     info['level_list'] = [N for N in info['level_list'] if (rad == ZZ(N).radical())]
             except (ValueError, TypeError):
                 pass


Test patch: