Skip to content

Fail to validate geneFilter[] #189

@eboileau

Description

@eboileau

A clear and concise description of what the bug is.

GET https://scimodom.dieterichlab.org/api/v0/modification/query?modification=3&organism=5&technology[]=6&rnaType=WTS&taxaId=9606&geneFilter[]=gene_name%252BASB1%252BstartsWith&geneFilter[]=gene_biotype%252BProtein+coding%252Bin&geneFilter[]=feature%252B3%27UTR%252Bin&firstRecord=0&maxRecords=10
  • Non-existing values for gene_name, gene_biotype, or feature fail to raise an error (empty list is returned). Should be handle this, e.g. checked in ModificationService and handled in the API, where a ClientResponseException could be raised?

  • The exact format for each of these filters requires 3 parts, separated by a "plus" (see also URL encode/decode fails different behavior GUI vs. API. #186 ). See error below. The exact value of each of these 3 parts is not validated, e.g. as long as a "plus" is there, the actual string can be empty, or gene_name, gene_biotype, feature can be replaced by anything (as well as their actual values, see point above). This can result in a list of records not exactly matching what is expected, or an empty list of records.

  • The matchMode (3rd part) is unused (cf. PrimeVue), but was kept to allow extending options or adding table filters. Is this still needed? We could simplify the query syntax otherwise.

Output or error messages.

cb557ec791d3 2025-06-30 10:43:56 [ERROR] scimodom | Exception on /api/v0/modification/query [GET]
cb557ec791d3 Traceback (most recent call last):
cb557ec791d3   File "/app/venv/lib/python3.11/site-packages/flask/app.py", line 1511, in wsgi_app
cb557ec791d3     response = self.full_dispatch_request()
cb557ec791d3                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
cb557ec791d3   File "/app/venv/lib/python3.11/site-packages/flask/app.py", line 919, in full_dispatch_request
cb557ec791d3     rv = self.handle_user_exception(e)
cb557ec791d3          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
cb557ec791d3   File "/app/venv/lib/python3.11/site-packages/flask_cors/extension.py", line 176, in wrapped_function
cb557ec791d3     return cors_after_request(app.make_response(f(*args, **kwargs)))
cb557ec791d3                                                 ^^^^^^^^^^^^^^^^^^
cb557ec791d3   File "/app/venv/lib/python3.11/site-packages/flask/app.py", line 917, in full_dispatch_request
cb557ec791d3     rv = self.dispatch_request()
cb557ec791d3          ^^^^^^^^^^^^^^^^^^^^^^^
cb557ec791d3   File "/app/venv/lib/python3.11/site-packages/flask/app.py", line 902, in dispatch_request
cb557ec791d3     return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]
cb557ec791d3            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
cb557ec791d3   File "/app/venv/lib/python3.11/site-packages/flask_cors/decorator.py", line 121, in wrapped_function
cb557ec791d3     resp = make_response(f(*args, **kwargs))
cb557ec791d3                          ^^^^^^^^^^^^^^^^^^
cb557ec791d3   File "/app/venv/lib/python3.11/site-packages/scimodom/api/modification.py", line 73, in get_modifications_as_json
cb557ec791d3     data = _get_modifications_for_request(by_gene)
cb557ec791d3            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
cb557ec791d3   File "/app/venv/lib/python3.11/site-packages/scimodom/api/modification.py", line 236, in _get_modifications_for_request
cb557ec791d3     return modification_service.get_modifications_by_source(
cb557ec791d3            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
cb557ec791d3   File "/app/venv/lib/python3.11/site-packages/scimodom/services/modification.py", line 98, in get_modifications_by_source
cb557ec791d3     query, length = self._return_ensembl_query(
cb557ec791d3                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^
cb557ec791d3   File "/app/venv/lib/python3.11/site-packages/scimodom/services/modification.py", line 366, in _return_ensembl_query
cb557ec791d3     query = self._get_gene_filters(query, gene_filter, annotation)
cb557ec791d3             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
cb557ec791d3   File "/app/venv/lib/python3.11/site-packages/scimodom/services/modification.py", line 317, in _get_gene_filters
cb557ec791d3     _, features, _ = self._get_flt(feature_flt)
cb557ec791d3                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
cb557ec791d3   File "/app/venv/lib/python3.11/site-packages/scimodom/services/modification.py", line 235, in _get_flt
cb557ec791d3     col, val, operator = string.split(url_split)
cb557ec791d3     ^^^^^^^^^^^^^^^^^^
cb557ec791d3 ValueError: not enough values to unpack (expected 3, got 2)

Additional context

On branch feature/ms15-api

What browser were you using?

Firefox

What version of Sci-ModoM were you using?

branch (specify above)

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions