Why cant i pass more then 1 variable to another function?

Viewed 44

I am getting TypeError: get_entity_id() takes 2 positional arguments but 4 were given

i am getting user input from a ajax form,

getFormData = (request.form)
reportName = (getFormData['reportName'])
districtName = (getFormData['districtName'])
rapid7Query = (getFormData['rapid7Query'])
rapid7SeverityLevel = (getFormData['rapid7SeverityLevel'])

Id like to be able to pass these to another python function

print("In post request response...")

response = insightvmreport.check_action(reportName, districtName, rapid7Query, rapid7SeverityLevel)

when i do this, im getting an error,

TypeError: get_entity_id() takes 2 positional arguments but 4 were given

I have the other function, accept the arguments... (in insightvmreport.py file, this is the check_action() function:

def check_action(reportName, districtName, rapid7Query, rapid7SeverityLevel):

    print(reportName, districtName, rapid7Query, rapid7SeverityLevel)
    action = "download"
    if action == "download":

        scan_id,site_id = get_entity_id(reportName, districtName, rapid7Query, rapid7SeverityLevel)

        if scan_id and site_id:

            response = configure_report(scan_id,site_id)

            return response

error:

test District 1 (EUR) SELECT * FROM dim_asset ORDER BY ip_address ASC Medium
[2022-09-21 11:48:05,216] ERROR in app: Exception on /rapid7/submit_report/process [POST]
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 2077, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1525, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1523, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1509, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
  File "/Users/s153152/Documents/Workspace/ssd_dashboard/app/bin/auth_functions.py", line 52, in decorated_view
    return func(*args, **kwargs)
  File "/Users/s153152/Documents/Workspace/ssd_dashboard/app/views/rapid7/view.py", line 44, in process
    response = insightvmreport.check_action(reportName, districtName, rapid7Query, rapid7SeverityLevel)
  File "/Users/s153152/Documents/Workspace/ssd_dashboard/services/rapid7/insightvmreport.py", line 19, in check_action
    scan_id,site_id = get_entity_id(reportName, districtName, rapid7Query, rapid7SeverityLevel)
TypeError: get_entity_id() takes 2 positional arguments but 4 were given
1 Answers

The function get_entity_id only takes two arguments. It has no idea what to do with more than two.

From your code it looks like you're trying to extract two entity ids, so you might need to split those two calls into two lines.

scan_id = get_entity_id(reportName, rapid7Query)
site_id = get_entity_id(districtName, rapid7SeverityLevel)

In order to use it twice (which I am assuming is your goal) you'll have to call it twice.

Related