Skip to content

I keep getting a "$return binding returned a non-None value" error. I can't figure it out? #294

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
epmck opened this issue Jun 13, 2021 · 6 comments

Comments

@epmck
Copy link

epmck commented Jun 13, 2021

I am trying to do a Durable Entity function locally, and I started trying to create my own. Every time I did I would get this error: Exception: RuntimeError: function 'DurableFunctionsEntityPy' without a $return binding returned a non-None value

So I finally found this project and I thought it would help me figure out what I'm doing wrong, but even when I clone this repo and try running it, I'm getting the same error. I swear there is no "return" in my Entity function. What is causing this issue? Please help, this is driving me crazy!

@counter@myCounter: Function 'counter (Entity)' failed with an error. Reason: Internal error: Microsoft.Azure.WebJobs.Script.Workers.Rpc.RpcException: Result: Failure
Exception: RuntimeError: function 'Counter' without a $return binding returned a non-None value

@ConnorMcMahon
Copy link

Can you share your function.json content with us? Given the error message it appears that this is the likely culprit.

@davidmrdavid
Copy link
Collaborator

Thanks for reaching out @epmck! Unless I'm mistaken, I believe we discussed this issue on Twitter about a week ago. In any case, I finally got around patching the sample to include this fix here: #296

The fix should be merged soon!

@davidmrdavid
Copy link
Collaborator

davidmrdavid commented Jun 25, 2021

Fix was merged! Closing this issue. Please re-open if the issue continues on your end. Thanks! :)

@FaCoffee1984
Copy link

FaCoffee1984 commented Aug 25, 2022

@davidmrdavid I see a similar error with my Python Durable Function (function chaining). The logs say:
RuntimeError: function 'function-name' without a $return binding returned a non-None value.

It sounds like this has been addressed with a fix in 2021, but why is it happening to me? As you can see, I have an output biding called outputDocument which my function is using to write data to a Cosmos DB, so I struggle to make sense of that error message. Does this have anything to do with the host.json file and the bundle version, perhaps?

My function.json:

{
  "scriptFile": "__init__.py",
  "bindings": [
    {
      "name": "data-from-previous-function",
      "type": "activityTrigger",
      "direction": "in"
    },
    {
      "type": "cosmosDB",
      "direction": "in",
      "name": "encoding",
      "databaseName": "database-name",
      "collectionName": "collection-name",
      "createIfNotExists": "true",
      "connectionStringSetting": "cosmos_conn_string",
      "partitionKey": "id",
      "sqlQuery": "SELECT TOP 1 * FROM c ORDER BY c._ts desc"
    },
    {
      "type": "cosmosDB",
      "direction": "out",
      "name": "outputDocument",
      "databaseName": "database-name",
      "collectionName": "collection-name",
      "createIfNotExists": "true",
      "connectionStringSetting": "cosmos_conn_string",
      "partitionKey": "id"
    }
  ]
}

My host.json:

{
  "version": "2.0",
  "logging": {
    "applicationInsights": {
      "samplingSettings": {
        "isEnabled": true,
        "excludedTypes": "Request"
      }
    }
  },
  "extensionBundle": {
    "id": "Microsoft.Azure.Functions.ExtensionBundle",
    "version": "[2.*, 3.0.0)"
  }
}

My __init__.py:

def main(data_from_previous_function, encoding, outputDocument: func.Out[func.Document]) -> str:

    inputDocument = data_from_previous_function.copy()

    #Logging
    if inputDocument:
        logging.info('Document id: %s', inputDocument['id'])

    #Read some values from Cosmos DB
    encodings = encoding[0].data 

    #Modify values in json file
    output_data = modify(inputDocument, encodings) # The result is a valid json file 
    
    # Send output to Cosmos DB
    outputDocument.set(func.Document.from_dict(output_data))    

    return output_data # Return data to Orchestrator for the next processing step in the function chain

@thec0dewriter
Copy link

Hello @FaCoffee1984
I've been facing this issue also for a few days, but I can't reproduce locally. I've opened a new ticket for it: #399

@davidmrdavid
Copy link
Collaborator

@FaCoffee1984, @thec0dewriter:

Thanks for your report. I have received a few of these over the past day, and it seems that some automatic upgrade may have caused a regression. I'm actively investigating this, so please subscribe to the following thread for updates: #401

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants