Zapier script returning output_missing error - need to define output or return early

I’m having trouble with my Zapier code step. It keeps giving me an error saying the output is missing and I need to define output or return early. The weird thing is that this code works fine when I have multiple arguments, but when there’s just one argument it fails.

Here’s what I’m trying to do:

try:
    file_data = {}
    if "Choose supporting files for your application" in form_input['selected_items']:
        file_data['document']="https://example-storage.s3.us-west-2.amazonaws.com/files/sample-document.pdf"
        return file_data
except:
    return {'no_data': True}

I’m trying to check if a specific checkbox option was selected in a form, and if it was, I want to return a dictionary with a document URL. If something goes wrong, I return an empty flag. What am I missing here? Any help would be great!

Your code’s failing because it doesn’t handle cases where the checkbox isn’t selected. When “Choose supporting files for your application” isn’t in form_input['selected_items'], the if block never runs and there’s no return statement before the except block kicks in. Add an else clause that returns a message when nothing’s selected - every code path in Zapier needs to return something or it’ll break.

Had this exact problem! Zapier needs every path to return something. Right now when the checkbox isn’t checked, your code just stops without returning anything. Add return {'status': 'no_files_selected'} after your if block but before the except - that’ll fix the output_missing error.

Your code’s breaking because when the checkbox isn’t selected, there’s no return statement. Zapier hits that missing return and throws the output_missing error. To fix this, add a return statement after your if block to ensure something is always returned, even if it’s just an empty dictionary. This way, you can avoid the output_missing error.