Repository: LMFDB/lmfdb

Issue:
missing validation of conrey labels at route level
```
Exception on /L/ModularForm/GL2/Q/holomorphic/7/4/0/a/ [GET]
Traceback (most recent call last):
  File "/home/sage/sage-10.1/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/flask/app.py", line 2073, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/sage/sage-10.1/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/flask/app.py", line 1519, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/sage/sage-10.1/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/flask/app.py", line 1517, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/sage/sage-10.1/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/flask/app.py", line 1503, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
  File "/home/lmfdb/lmfdb-git-web/lmfdb/lfunctions/main.py", line 987, in l_function_cmf_redirect_1
    min_character = ConreyCharacter(modulus=level,number=character).min_conrey_conj
  File "/home/lmfdb/lmfdb-git-web/lmfdb/characters/TinyConrey.py", line 103, in __init__
    assert gcd(modulus, number)==1
AssertionError
[2023-10-25 07:01:22 UTC] 500 error on URL https://www.lmfdb.org/L/ModularForm/GL2/Q/holomorphic/7/4/0/a/ ()
missing validation of conrey labels at route level
```
Exception on /L/ModularForm/GL2/Q/holomorphic/7/4/0/a/ [GET]
Traceback (most recent call last):
  File "/home/sage/sage-10.1/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/flask/app.py", line 2073, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/sage/sage-10.1/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/flask/app.py", line 1519, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/sage/sage-10.1/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/flask/app.py", line 1517, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/sage/sage-10.1/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/flask/app.py", line 1503, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
  File "/home/lmfdb/lmfdb-git-web/lmfdb/lfunctions/main.py", line 987, in l_function_cmf_redirect_1
    min_character = ConreyCharacter(modulus=level,number=character).min_conrey_conj
  File "/home/lmfdb/lmfdb-git-web/lmfdb/characters/TinyConrey.py", line 103, in __init__
    assert gcd(modulus, number)==1
AssertionError
[2023-10-25 07:01:22 UTC] 500 error on URL https://www.lmfdb.org/L/ModularForm/GL2/Q/holomorphic/7/4/0/a/ ()


Discussion:

Resolving patch:
diff --git a/lmfdb/lfunctions/main.py b/lmfdb/lfunctions/main.py
--- a/lmfdb/lfunctions/main.py
+++ b/lmfdb/lfunctions/main.py
@@ -991,6 +991,9 @@ def l_function_cmf_old(level, weight, character, hecke_orbit, number):
 
 @l_function_page.route("/ModularForm/GL2/Q/holomorphic/<int:level>/<int:weight>/<int:character>/<hecke_orbit>/")
 def l_function_cmf_redirect_1(level, weight, character, hecke_orbit):
+    if GCD(level, character) != 1:
+        flash_error("%s", 'Level and character must be coprime')
+        return redirect(url_for(".index"))
     min_character = ConreyCharacter(modulus=level,number=character).min_conrey_conj
     char_orbit_label = db.mf_newspaces.lucky({'conrey_index': min_character, 'level': level, 'weight': weight}, projection='char_orbit_label')
     if char_orbit_label is None:


Test patch: