elixir-cloud-aai / proTES

Proxy service for injecting middleware into GA4GH TES requests
Apache License 2.0
5 stars 6 forks source link

ignore Funnel basic credential if task submitted to TESK #151

Closed vschnei closed 1 year ago

vschnei commented 1 year ago

Describe the bug I am reproducing Alex's "hashsplitter" CWLworkflow but this time using snakemake. For this Snakemake will be extended to forward FUNNEL_SERVER_USER and FUNNEL_SERVER_PASSWORD to py-tes via envvars. In my use case the "hashsplitter" tasks are submitted to proTES:

snakemake --tes "https://protes.rahtiapp.fi/ga4gh/tes/" --snakefile Snakefile_s3 --jobs 1 --cores 1 --envvars HOME FUNNEL_SERVER_USER FUNNEL_SERVER_PASSWORD

Depending on where proTES sends the task, the task is either executed or not. For Funnel the execution works fine while TESK shows the following error:

[2023-03-20 14:33:16,825: ERROR ] Traceback (most recent call last):\n File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1516, in full_dispatch_request\n rv = self.dispatch_request()\n File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1502, in dispatch_request\n return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)\n File "/usr/local/lib/python3.10/site-packages/connexion/decorators/decorator.py", line 68, in wrapper\n response = function(request)\n File "/usr/local/lib/python3.10/site-packages/connexion/decorators/uri_parsing.py", line 149, in wrapper\n response = function(request)\n File "/usr/local/lib/python3.10/site-packages/connexion/decorators/validation.py", line 193, in wrapper\n response = function(request)\n File "/usr/local/lib/python3.10/site-packages/connexion/decorators/parameter.py", line 116, in wrapper\n return function(**kwargs)\n File "/usr/local/lib/python3.10/site-packages/foca/utils/logging.py", line 61, in _wrapper\n response = fn(*args, **kwargs)\n File "/app/pro_tes/ga4gh/tes/server.py", line 45, in CreateTask\n response = task_runs.create_task(request=request, **kwargs)\n File "/app/pro_tes/ga4gh/tes/task_runs.py", line 152, in create_task\n input.url = remove_auth_from_url(input.url)\n File "/app/pro_tes/utils/misc.py", line 19, in remove_auth_from_url\n elements[1] = elements[1][elements[1].rfind("@") + 1 :] # noqa: E203\nTypeError: argument should be integer or bytes-like object, not 'str' [foca.errors.exceptions]

According to the traceback, proTES tries to remove basic authentication information which is not part of the URI.

To Reproduce Steps to reproduce the behavior:

  1. clone https://github.com/DMBS-BIH/hybrid-cloud-snakemake-demo and complete/adjust the Snakemake_s3 workflow
  2. clone the latest Snakemake repo install the "tes_auth" fork. Not yet merged into the main branch.
  3. export HOME=/tmp
  4. source .env as described in https://github.com/elixir-cloud-aai/elixir-cloud-demos/blob/main/demos/2023-ecp-f2f/demo.ipynb
  5. ecexute: snakemake --tes "https://protes.rahtiapp.fi/ga4gh/tes/" --snakefile Snakefile_s3 --jobs 1 --cores 1 --envvars HOME FUNNEL_SERVER_USER FUNNEL_SERVER_PASSWORD

Expected behavior Task successfully submitted to the random TES instances.

Software

uniqueg commented 1 year ago

Thanks @vschnei. Did you try what we discussed on Slack?

vschnei commented 1 year ago

Just did a deployment of proTES locally and did some logs. The Snakemake request/payload does not contain any URL. So in ../pro_tes/ga4gh/tes/task_runs.py:147 onward in the method create_task the empty ulr is passed to remove_auth_from_url wich triggers the observed error. Made a small fix by double checking if URL is present at all. check if url is present