Skip to content

URL encode/decode fails different behavior GUI vs. API. #186

@eboileau

Description

@eboileau

A clear and concise description of what the bug is.

A query with gene name fails via the API, the server receives gene_name+ACTB+startsWith.

On the GUI, e.g.

https://scimodom.dieterichlab.org/api/v0/modification/query/gene?rnaType=WTS&taxaId=9606&geneFilter[]=gene_name%2BACTB%2BstartsWith&firstRecord=0&maxRecords=10]

works fine, but it looks like that + is double-encoded, when running in debug mode we can see in the console

GET /api/v0/modification/query/gene?rnaType=WTS&taxaId=9606&geneFilter[]=gene_name%252BACTB%252BstartsWith&firstRecord=0&maxRecords=10 HTTP/1.1" 200

So if we want the API call to succeed, we need to write

https://scimodom.dieterichlab.org/api/v0/modification/query/gene?rnaType=WTS&taxaId=9606&geneFilter[]=gene_name%252BACTB%252BstartsWith&firstRecord=0&maxRecords=10]

I don't think this is done right.

Output or error messages.

bc0dab844a16 2025-05-05 12:34:32 [ERROR] scimodom | Exception on /api/v0/modification/query/gene [GET]
bc0dab844a16 Traceback (most recent call last):
bc0dab844a16   File "/app/venv/lib/python3.11/site-packages/flask/app.py", line 1511, in wsgi_app
bc0dab844a16     response = self.full_dispatch_request()
bc0dab844a16                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
bc0dab844a16   File "/app/venv/lib/python3.11/site-packages/flask/app.py", line 919, in full_dispatch_request
bc0dab844a16     rv = self.handle_user_exception(e)
bc0dab844a16          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
bc0dab844a16   File "/app/venv/lib/python3.11/site-packages/flask_cors/extension.py", line 176, in wrapped_function
bc0dab844a16     return cors_after_request(app.make_response(f(*args, **kwargs)))
bc0dab844a16                                                 ^^^^^^^^^^^^^^^^^^
bc0dab844a16   File "/app/venv/lib/python3.11/site-packages/flask/app.py", line 917, in full_dispatch_request
bc0dab844a16     rv = self.dispatch_request()
bc0dab844a16          ^^^^^^^^^^^^^^^^^^^^^^^
bc0dab844a16   File "/app/venv/lib/python3.11/site-packages/flask/app.py", line 902, in dispatch_request
bc0dab844a16     return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]
bc0dab844a16            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
bc0dab844a16   File "/app/venv/lib/python3.11/site-packages/flask_cors/decorator.py", line 121, in wrapped_function
bc0dab844a16     resp = make_response(f(*args, **kwargs))
bc0dab844a16                          ^^^^^^^^^^^^^^^^^^
bc0dab844a16   File "/app/venv/lib/python3.11/site-packages/scimodom/api/modification.py", line 73, in get_modifications_as_json
bc0dab844a16     data = _get_modifications_for_request(by_gene)
bc0dab844a16            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
bc0dab844a16   File "/app/venv/lib/python3.11/site-packages/scimodom/api/modification.py", line 224, in _get_modifications_for_request
bc0dab844a16     return modification_service.get_modifications_by_gene(
bc0dab844a16            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
bc0dab844a16   File "/app/venv/lib/python3.11/site-packages/scimodom/services/modification.py", line 162, in get_modifications_by_gene
bc0dab844a16     query, length = self._return_gene_query(
bc0dab844a16                     ^^^^^^^^^^^^^^^^^^^^^^^^
bc0dab844a16   File "/app/venv/lib/python3.11/site-packages/scimodom/services/modification.py", line 399, in _return_gene_query
bc0dab844a16     query = self._get_gene_filters(query, gene_filter, annotation)
bc0dab844a16             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
bc0dab844a16   File "/app/venv/lib/python3.11/site-packages/scimodom/services/modification.py", line 312, in _get_gene_filters
bc0dab844a16     _, name, _ = self._get_flt(name_flt)
bc0dab844a16                  ^^^^^^^^^^^^^^^^^^^^^^^
bc0dab844a16   File "/app/venv/lib/python3.11/site-packages/scimodom/services/modification.py", line 235, in _get_flt
bc0dab844a16     col, val, operator = string.split(url_split)
bc0dab844a16     ^^^^^^^^^^^^^^^^^^
bc0dab844a16 ValueError: not enough values to unpack (expected 3, got 1)

Additional context

No response

What browser were you using?

Firefox

What version of Sci-ModoM were you using?

latest release, master

Metadata

Metadata

Assignees

Labels

type:bugSomething isn't working

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions