GoogleCloudPlatform / cdmc

Apache License 2.0
21 stars 7 forks source link

Tagging remote_functions: get_ultimate_source error #40

Open swainjo opened 1 year ago

swainjo commented 1 year ago

error when calling get_ultimate_source remote function created by: bytes_transferred/create_remote_function.sh

Test SQL select cdmc-gov-388611.remote_functions.get_ultimate_source('cdmc-gov-388611', 531184339140, 'us-central1', 'crm', 'NewCust');

Error in cloud Function: get_ultimate_source0s1ubz2m0673 Exception on / [POST] Traceback (most recent call last): File "/layers/google.python.pip/pip/lib/python3.7/site-packages/flask/app.py", line 2073, in wsgi_app response = self.full_dispatch_request() File "/layers/google.python.pip/pip/lib/python3.7/site-packages/flask/app.py", line 1518, in full_dispatch_request rv = self.handle_user_exception(e) File "/layers/google.python.pip/pip/lib/python3.7/site-packages/flask/app.py", line 1516, in full_dispatch_request rv = self.dispatch_request() File "/layers/google.python.pip/pip/lib/python3.7/site-packages/flask/app.py", line 1502, in dispatch_request return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args) File "/layers/google.python.pip/pip/lib/python3.7/site-packages/functions_framework/init.py", line 130, in view_func return function(request._get_current_object()) File "/workspace/main.py", line 45, in process_request ultimate_source = get_source_links(table, project_num, region) File "/workspace/main.py", line 66, in get_source_links headers = {'Authorization' : 'Bearer ' + get_credentials_from_environment()} File "/workspace/main.py", line 54, in get_credentials_from_environment service_account_info = json.loads(secret) File "/layers/google.python.runtime/python/lib/python3.7/json/init.py", line 341, in loads raise TypeError(f'the JSON object must be str, bytes or bytearray, ' TypeError: the JSON object must be str, bytes or bytearray, not NoneType

Diagnosis

This function is looking for the user key passed in as as environment variable. Do we have an standard approach to passing this key in via environment variables or secret manager?

def get_credentials_from_environment(): secret = os.getenv('SECRET')