dispatchrun/dispatch-py

Better handling of language usage errors

Closed this issue · 1 comments

Here is a script that motivated opening this issue:

from fastapi import FastAPI
from dispatch.fastapi import Dispatch

app = FastAPI()
dispatch = Dispatch(app)

@dispatch.function()
def publish(arg: str) -> str:
    r = requests.post('https://httpstat.us/200', data={'arg': arg})
    r.raise_for_status()
    return 'OK'

@app.get('/')
def endpoint():
    publish.dispatch('hello')
    return {'message': 'ok'}

The problem is there is no symbol named requests, because we forgot the import requests statement. That is supposed to raise a NameError. This error type is currently interpreted as retriable, which silences it and causes the operation to retry.

It is difficult for users to understand what they did wrong in this situation because we capture and handle the exceptions.

  • I wonder if we could default to logging certain classes of errors like those reporting misuse of the Python language.
  • What about retries? Some of those errors indicate something seriously broken with the program, maybe we should consider them to be permanent failures?
chriso commented

IMO errors should default to PERMANENT_ERROR, and retries should be opt-in. At the moment the default is TEMPORARY_ERROR.