Suddenly getting "Script returned exit code 1" error for Python step when workflow has been working perfectly for months now

Hi :slight_smile:

I have a Python step in between two Google Sheets steps in a workflow that has been working perfectly since December 2022. At the end of April 2023, the workflow stopped working. Since I only learned enough code to get this set up, I’m having trouble figuring out the issue and how to fix it. The only thing that stood out to me is that the syntax for passing information between steps has changed. However, when I checked the documentation, they still have the old syntax up.

I’m attaching what my Python step looks like, the full error I get, and the Github page for the package I’m using. Thanks for any guidance!

from pipedream.script_helpers import (steps, export)
from ao3 import AO3
import requests
from bs4 import BeautifulSoup as bs
api = AO3()

import pytest

from ao3 import utils


@pytest.mark.parametrize('url, work_id', [
    ('https://archiveofourown.org/works/1', '1'),
    ('https://archiveofourown.org/works/1234567', '1234567'),
    ('https://archiveofourown.org/works/1?view_adult=true', '1'),
    ('https://archiveofourown.org/works/1234567?view_adult=true', '1234567'),
    ('http://archiveofourown.org/works/1?view_adult=true', '1'),
    ('http://archiveofourown.org/works/1234567?view_adult=true', '1234567'),
])
def test_work_id_from_url(url, work_id):
    assert utils.work_id_from_url(url) == work_id


@pytest.mark.parametrize('bad_url', [
    'http://google.co.uk',
    'http://archiveofourown.org/users/username',
])
def test_work_id_from_bad_url_raises_runtimeerror(bad_url):
    """Trying to get a work ID from a non-work URL raises a RuntimeError."""
    with pytest.raises(RuntimeError) as exc:
        utils.work_id_from_url(bad_url)
    assert 'not a recognised AO3 work URL' in exc.value.message

read_fic = steps["trigger"]["event"]["changes"][1]["new_value"]
work = api.work(read_fic)
url = 'https://archiveofourown.org/works/'
r = requests.get(url)
soup = bs(r.content, 'html.parser')
info = work.url, work.title, work.author, work.rating, work.fandoms, work.relationship, work.additional_tags, work.words


export('Title', str(work.title))
export('Author', str(work.author))

target = {39:None, 91:None , 93:None}
export('Fandom', str(work.fandoms).translate(target))

export('Ship', str(work.relationship).translate(target))

export('Category', str(work.category).translate(target))

export('Word Count', int(work.words))

export('Rating', str(work.rating).translate(target))

export('Tags', str(work.additional_tags).translate(target))

export('URL', str(work.url))

Hi @lovelightwings,

I’m sorry to hear that your workflow stopped working. Based on the information you provided, it’s difficult to pinpoint the exact issue without more details about the error message you’re encountering. However, I’ll do my best to help you.

First, please make sure that the AO3 package and any other dependencies are up-to-date and compatible with the current version of Python you’re using in your Pipedream workflow.

Next, double-check if there were any changes in the AO3 package or the Google Sheets steps that might have caused the issue.

If you’re still having trouble, please provide more information about the error message you’re encountering, and I’ll do my best to help you further. Additionally, you can visit https://pipedream.com/support for more support options. Pipedream offers a range of community support options. Advanced customers get access to email and community support. Business customers get a dedicated account rep, and a Slack channel with the Pipedream team.
I’m a bot powered by Pipedream and GPT-4. I’m still learning, so please double check my answers and code! Learn how to build your own.

Hi @lovelightwings, Pipedream Python code step now require you to define your function code in a handler function that receive the pipedream param having the steps info.

You can refer to the example in Pipedream builder UI as this

I think the migration should be quite straight forward. You can code it yourself and/or asking AI assistance such as ChatGPT or Google Bard