What is the solution to this error?

This topic was automatically generated from Slack. You can find the original thread here.

hey everyone, can you help with this error please?

Hi , I believe you’re using Python code step, would you mind sharing your code for us to reproduce?

hey, thank you. yes for sure, im new to the platform how do i do it?

import requests

def handler(pd: “pipedream”):
authorization = f’Bearer {pd.inputs[“google_sheets”][“$auth”][“oauth_access_token”]}’
headers = {“Authorization”: authorization}
spreadsheetId = ‘1NHDJwVGrjSeaDjsyVGC8JESzex489GCGMXnxWz_2VoM’
subreddit = pd.steps[“trigger”][“event”][“data”][“subreddit”]
range = f"{subreddit}!A:Z"

body = {
‘majorDimension’:‘ROWS’,
‘values’: [
[
pd.steps[“trigger”][“event”][“data”][“title”],
pd.steps[“trigger”][“event”][“data”][“permalink”],
pd.steps[“Sentiment_analysis”][“sentiment”][“neg”],
pd.steps[“Sentiment_analysis”][“sentiment”][“neu”],
pd.steps[“Sentiment_analysis”][“sentiment”][“pos”],
pd.steps[“Sentiment_analysis”][“sentiment”][“compound”],
pd.steps[“trigger”][“event”][“data”][“num_comments”],
pd.steps[“trigger”][“event”][“data”][“created_utc”]
]
]
}

params= {
‘valueInputOption’: ‘USER_ENTERED’
}
r = requests.POST(f"https://sheets.googleapis.com/v4/spreadsheets/{spreadsheetId}/values/{range}:append", headers=headers, json=body, params=params)

# Export the data for use in future steps
pd.export(“data”, r.json())

Thanks Hello @U02SX7ETBFB, could you advice how to solve this error? I suspect it is something related to dependencies installation.

Hi , thanks for taking a screenshot of the error, you can see near the very end of the long text that it mentions an indentation error. Please check your indentation on that particular line it describes and make sure it’s correct

Hi Pierce, i played around with the indentation but it doesn’t seem to give me any luck… is it something you can access from your end?

Hi , I think the params part (Line 26) has an invalid indent. I would suggest you paste the code into an IDE (Visual Code for example), for it to check the python indentation?

Thanks guys. Got a new error now if you have seen this before?

image.png

This is a known issue with Python steps specifically:

The error essentially means that you have an exception thrown during the execution of the Python code, but it doesn’t provide much detail unfortunately.

Could you add your example as a comment to that thread?

Ah ok, and there is no solution? I won’t be able to make it work?

There is no solution to the opaque error message unfortunately. But the error message means that somewhere in your python code you have an exception thrown during execution.

That is fixable, but the details of the error trace aren’t visible at the moment.

Is there way to manipulate the code for it to show an error or something?

The other suggestion I have is to wrap your code inside the pd handler with a begin…except block so you can print the error to the logs