MathematicalMedicine / diver-issues

Semipublic tracking of issues for the DIVER front end
0 stars 0 forks source link

Error in combining two variables when [UNK] isn't used #250

Closed Viqsi closed 3 months ago

Viqsi commented 3 months ago

Reported by Jake:

Attempted to combine V1563 and OPCRIT74, but after filling information for the custom variable and clicking “Save Custom Variable”, got a “! Failed to save Custom Variable” message.

Request info:

[2024-08-26 09:09:50,143] DEBUG in diverRPC: ------------------ start request ------------------
[2024-08-26 09:09:50,146] DEBUG in diverRPC: 127.0.0.1 POST https:///api/v0/construct/new? | Args: None | Body: {'construct_type': 'merge',
 'defaultValue': None,
 'description': 'Presence of auditory hallucinations of voices commenting',
 'name': 'commenting_voices',
 'values': [None,
            {'definition': {'constraints': [{'constraints': [{'constraint_type': 'EQ',
                                                              'constraint_value': '1',
                                                              'variable_name': 'V1563'},
                                                             {'constraint_type': 'EQ',
                                                              'constraint_value': '0',
                                                              'variable_name': 'OPCRIT74'}],
                                             'relationship': 'AND'},
                                            {'constraints': [{'constraint_type': 'EQ',
                                                              'constraint_value': '1',
                                                              'variable_name': 'V1563'},
                                                             {'constraint_type': 'EQ',
                                                              'constraint_value': '1',
                                                              'variable_name': 'OPCRIT74'}],
                                             'relationship': 'AND'},
                                            {'constraints': [{'constraint_type': 'EQ',
                                                              'constraint_value': '1',
                                                              'variable_name': 'V1563'},
                                                             {'constraint_type': 'EQ',
                                                              'constraint_value': '2',
                                                              'variable_name': 'OPCRIT74'}],
                                             'relationship': 'AND'},
                                            {'constraints': [{'constraint_type': 'EQ',
                                                              'constraint_value': '0',
                                                              'variable_name': 'V1563'},
                                                             {'constraint_type': 'EQ',
                                                              'constraint_value': '1',
                                                              'variable_name': 'OPCRIT74'}],
                                             'relationship': 'AND'},
                                            {'constraints': [{'constraint_type': 'EQ',
                                                              'constraint_value': '[UNK]',
                                                              'variable_name': 'V1563'},
                                                             {'constraint_type': 'EQ',
                                                              'constraint_value': '1',
                                                              'variable_name': 'OPCRIT74'}],
                                             'relationship': 'AND'},
                                            {'constraints': [{'constraint_type': 'EQ',
                                                              'constraint_value': '0',
                                                              'variable_name': 'V1563'},
                                                             {'constraint_type': 'EQ',
                                                              'constraint_value': '2',
                                                              'variable_name': 'OPCRIT74'}],
                                             'relationship': 'AND'},
                                            {'constraints': [{'constraint_type': 'EQ',
                                                              'constraint_value': '[UNK]',
                                                              'variable_name': 'V1563'},
                                                             {'constraint_type': 'EQ',
                                                              'constraint_value': '2',
                                                              'variable_name': 'OPCRIT74'}],
                                             'relationship': 'AND'}],
                            'relationship': 'OR'},
             'description': '',
             'name': 'yes'},
            {'definition': {'constraints': [{'constraints': [{'constraint_type': 'EQ',
                                                              'constraint_value': '[UNK]',
                                                              'variable_name': 'V1563'},
                                                             {'constraint_type': 'EQ',
                                                              'constraint_value': '0',
                                                              'variable_name': 'OPCRIT74'}],
                                             'relationship': 'AND'},
                                            {'constraints': [{'constraint_type': 'EQ',
                                                              'constraint_value': '0',
                                                              'variable_name': 'V1563'},
                                                             {'constraint_type': 'EQ',
                                                              'constraint_value': '0',
                                                              'variable_name': 'OPCRIT74'}],
                                             'relationship': 'AND'}],
                            'relationship': 'OR'},
             'description': '',
             'name': 'not_yes'}],
 'variable_limit': 2,
 'variables': ['V1563', 'OPCRIT74']}
[2024-08-26 09:09:50,331] DEBUG in connectionpool: https://auth.isi.edu:443 "POST /rest/usermanagement/1/session/IfdauRPbRgEKJaUtVP9JIQAAAAAACgADanRzMjQw?expand=user HTTP/1.1" 200 878
[2024-08-26 09:09:50,331] DEBUG in diverRPC: Token check result: {'expand': 'user', 'token': 'IfdauRPbRgEKJaUtVP9JIQAAAAAACgADanRzMjQw', 'user': {'expand': 'attributes', 'link': {'href': 'https://auth.isi.edu/rest/usermanagement/1/user?username=jts240', 'rel': 'self'}, 'name': 'jts240', 'first-name': 'Jake', 'last-name': 'Smolinsky', 'display-name': 'Jake Smolinsky', 'email': 'jts240@hginj.rutgers.edu', 'password': {'link': {'href': 'https://auth.isi.edu/rest/usermanagement/1/user/password?username=jts240', 'rel': 'edit'}}, 'key': '655363:178282fa-59bc-47c7-b801-0915310cf072', 'created-date': 1675274228000, 'updated-date': 1708702198000, 'active': True, 'attributes': {'attributes': [], 'link': {'href': 'https://auth.isi.edu/rest/usermanagement/1/user/attribute?username=jts240', 'rel': 'self'}}}, 'link': {'href': 'https://auth.isi.edu/rest/usermanagement/1/session/IfdauRPbRgEKJaUtVP9JIQAAAAAACgADanRzMjQw', 'rel': 'self'}, 'created-date': 1718196440000, 'expiry-date': 1725109790265}
[2024-08-26 09:09:50,454] DEBUG in connectionpool: https://auth.isi.edu:443 "GET /rest/usermanagement/1/user/group/nested?username=jts240 HTTP/1.1" 200 1647
[2024-08-26 09:09:50,455] DEBUG in diverRPC: Validated user: CrowdUser(name='jts240', privs='["admin"]')
[2024-08-26 09:09:50,468] ERROR in diverRPC: ERROR DETAILS: {'message': 'Unhandled application error'}, 500
Traceback (most recent call last):
  File "/var/lib/diver/mambaforge/lib/python3.9/site-packages/flask/app.py", line 1523, in full_dispatch_request
    rv = self.dispatch_request()
  File "/var/lib/diver/mambaforge/lib/python3.9/site-packages/flask/app.py", line 1509, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
  File "/var/lib/diver/diverRPC/diverRPC.py", line 409, in get_verified_user
    return endpoint(verify_user(), *args, **kwargs)
  File "/var/lib/diver/diverRPC/diverRPC.py", line 889, in route_new_construct
    return flask.jsonify(diverAPI.new_construct(user, projectid, name,
  File "/var/lib/diver/diverRPC/diverAPI.py", line 866, in new_construct
    jsonschema.validate(instance=construct_values,
  File "/var/lib/diver/mambaforge/lib/python3.9/site-packages/jsonschema/validators.py", line 1312, in validate
    raise error
jsonschema.exceptions.ValidationError: None is not of type 'object'

Failed validating 'type' in schema['items']:
    {'additionalProperties': False,
     'description': 'One of an ordered list of possible values for a '
                    'custom variable.',
     'properties': {'definition': {'$ref': '#/$defs/Definition'},
                    'description': {'type': 'string'},
                    'name': {'description': 'Actually the value to be used '
                                            'if constraints are satisfied.',
                             'pattern': '^([a-zA-Z0-9_+?,. '
                                        '-]{1,48}|\\[UNK])$',
                             'type': 'string'}},
     'required': ['name'],
     'title': 'Value',
     'type': 'object'}

On instance[0]:
    None

[2024-08-26 09:09:50,468] DEBUG in diverRPC: ------------------- end request -------------------
[2024-08-26 09:10:24,252] DEBUG in diverRPC: ------------------ start request ------------------
[2024-08-26 09:10:24,263] DEBUG in diverRPC: 127.0.0.1 POST https:///api/v0/construct/new? | Args: None | Body: {'construct_type': 'merge',
 'defaultValue': None,
 'description': 'Presence of auditory hallucinations of voices commenting',
 'name': 'commenting_voices',
 'values': [None,
            {'definition': {'constraints': [{'constraints': [{'constraint_type': 'EQ',
                                                              'constraint_value': '1',
                                                              'variable_name': 'V1563'},
                                                             {'constraint_type': 'EQ',
                                                              'constraint_value': '0',
                                                              'variable_name': 'OPCRIT74'}],
                                             'relationship': 'AND'},
                                            {'constraints': [{'constraint_type': 'EQ',
                                                              'constraint_value': '1',
                                                              'variable_name': 'V1563'},
                                                             {'constraint_type': 'EQ',
                                                              'constraint_value': '1',
                                                              'variable_name': 'OPCRIT74'}],
                                             'relationship': 'AND'},
                                            {'constraints': [{'constraint_type': 'EQ',
                                                              'constraint_value': '1',
                                                              'variable_name': 'V1563'},
                                                             {'constraint_type': 'EQ',
                                                              'constraint_value': '2',
                                                              'variable_name': 'OPCRIT74'}],
                                             'relationship': 'AND'},
                                            {'constraints': [{'constraint_type': 'EQ',
                                                              'constraint_value': '0',
                                                              'variable_name': 'V1563'},
                                                             {'constraint_type': 'EQ',
                                                              'constraint_value': '1',
                                                              'variable_name': 'OPCRIT74'}],
                                             'relationship': 'AND'},
                                            {'constraints': [{'constraint_type': 'EQ',
                                                              'constraint_value': '[UNK]',
                                                              'variable_name': 'V1563'},
                                                             {'constraint_type': 'EQ',
                                                              'constraint_value': '1',
                                                              'variable_name': 'OPCRIT74'}],
                                             'relationship': 'AND'},
                                            {'constraints': [{'constraint_type': 'EQ',
                                                              'constraint_value': '0',
                                                              'variable_name': 'V1563'},
                                                             {'constraint_type': 'EQ',
                                                              'constraint_value': '2',
                                                              'variable_name': 'OPCRIT74'}],
                                             'relationship': 'AND'},
                                            {'constraints': [{'constraint_type': 'EQ',
                                                              'constraint_value': '[UNK]',
                                                              'variable_name': 'V1563'},
                                                             {'constraint_type': 'EQ',
                                                              'constraint_value': '2',
                                                              'variable_name': 'OPCRIT74'}],
                                             'relationship': 'AND'}],
                            'relationship': 'OR'},
             'description': 'positive response',
             'name': 'yes'},
            {'definition': {'constraints': [{'constraints': [{'constraint_type': 'EQ',
                                                              'constraint_value': '[UNK]',
                                                              'variable_name': 'V1563'},
                                                             {'constraint_type': 'EQ',
                                                              'constraint_value': '0',
                                                              'variable_name': 'OPCRIT74'}],
                                             'relationship': 'AND'},
                                            {'constraints': [{'constraint_type': 'EQ',
                                                              'constraint_value': '0',
                                                              'variable_name': 'V1563'},
                                                             {'constraint_type': 'EQ',
                                                              'constraint_value': '0',
                                                              'variable_name': 'OPCRIT74'}],
                                             'relationship': 'AND'}],
                            'relationship': 'OR'},
             'description': 'nos or unknowns',
             'name': 'not_yes'}],
 'variable_limit': 2,
 'variables': ['V1563', 'OPCRIT74']}
[2024-08-26 09:10:24,420] DEBUG in connectionpool: https://auth.isi.edu:443 "POST /rest/usermanagement/1/session/IfdauRPbRgEKJaUtVP9JIQAAAAAACgADanRzMjQw?expand=user HTTP/1.1" 200 878
[2024-08-26 09:10:24,421] DEBUG in diverRPC: Token check result: {'expand': 'user', 'token': 'IfdauRPbRgEKJaUtVP9JIQAAAAAACgADanRzMjQw', 'user': {'expand': 'attributes', 'link': {'href': 'https://auth.isi.edu/rest/usermanagement/1/user?username=jts240', 'rel': 'self'}, 'name': 'jts240', 'first-name': 'Jake', 'last-name': 'Smolinsky', 'display-name': 'Jake Smolinsky', 'email': 'jts240@hginj.rutgers.edu', 'password': {'link': {'href': 'https://auth.isi.edu/rest/usermanagement/1/user/password?username=jts240', 'rel': 'edit'}}, 'key': '655363:178282fa-59bc-47c7-b801-0915310cf072', 'created-date': 1675274228000, 'updated-date': 1708702198000, 'active': True, 'attributes': {'attributes': [], 'link': {'href': 'https://auth.isi.edu/rest/usermanagement/1/user/attribute?username=jts240', 'rel': 'self'}}}, 'link': {'href': 'https://auth.isi.edu/rest/usermanagement/1/session/IfdauRPbRgEKJaUtVP9JIQAAAAAACgADanRzMjQw', 'rel': 'self'}, 'created-date': 1718196440000, 'expiry-date': 1725109824356}
[2024-08-26 09:10:24,540] DEBUG in connectionpool: https://auth.isi.edu:443 "GET /rest/usermanagement/1/user/group/nested?username=jts240 HTTP/1.1" 200 1647
[2024-08-26 09:10:24,541] DEBUG in diverRPC: Validated user: CrowdUser(name='jts240', privs='["admin"]')
[2024-08-26 09:10:24,548] ERROR in diverRPC: ERROR DETAILS: {'message': 'Unhandled application error'}, 500
Traceback (most recent call last):
  File "/var/lib/diver/mambaforge/lib/python3.9/site-packages/flask/app.py", line 1523, in full_dispatch_request
    rv = self.dispatch_request()
  File "/var/lib/diver/mambaforge/lib/python3.9/site-packages/flask/app.py", line 1509, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
  File "/var/lib/diver/diverRPC/diverRPC.py", line 409, in get_verified_user
    return endpoint(verify_user(), *args, **kwargs)
  File "/var/lib/diver/diverRPC/diverRPC.py", line 889, in route_new_construct
    return flask.jsonify(diverAPI.new_construct(user, projectid, name,
  File "/var/lib/diver/diverRPC/diverAPI.py", line 866, in new_construct
    jsonschema.validate(instance=construct_values,
  File "/var/lib/diver/mambaforge/lib/python3.9/site-packages/jsonschema/validators.py", line 1312, in validate
    raise error
jsonschema.exceptions.ValidationError: None is not of type 'object'

Failed validating 'type' in schema['items']:
    {'additionalProperties': False,
     'description': 'One of an ordered list of possible values for a '
                    'custom variable.',
     'properties': {'definition': {'$ref': '#/$defs/Definition'},
                    'description': {'type': 'string'},
                    'name': {'description': 'Actually the value to be used '
                                            'if constraints are satisfied.',
                             'pattern': '^([a-zA-Z0-9_+?,. '
                                        '-]{1,48}|\\[UNK])$',
                             'type': 'string'}},
     'required': ['name'],
     'title': 'Value',
     'type': 'object'}

On instance[0]:
    None

[2024-08-26 09:10:24,548] DEBUG in diverRPC: ------------------- end request -------------------

On further inspection, it looks like something in Combine Two is deleting the empty "Unknown" that's pre-provided and replacing it with a null, which is confusing our validator.