I am using Google cloud functions, and has deployed and had been using 2nd gen functions with flask applications. I am using Hasura actions to trigger these functions. Recently after I updated and deployed my code, it started showing headers that I passed from Hasura actions as None
. All cloud functions other than that which I updated was getting the headers. Has anyone got this issue of not receiving the headers that was sent?
To confirm, I updated one more cloud function and that too started acting the same way. I have logged all the headers that I am receiving in the cloud functions and confirmed that it was not any spelling mistakes or that kind of errors.
I am using python version 3.11 and cloud function 2nd gen.
import json
@functions_framework.http
def main(request):
try:
action_secret = request.headers.get("action_secret")
if action_secret != os.environ.get("action_secret"):
logging.error("Unauthorized access")
return json.dumps(
{"err_msg": "You are not authorized to perform this action"}
)
except Exception as e:
print(e) # I get the error log as action_secret is not in request.headers
Update:
Found out that the error was caused due to an underscore in the hasura action client headers. The variable I used was 'action_secret' and when I modified that into 'actionsecret', the cloud functions started working normally.