Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Confusing error message when non-iterable input used with outputs #331

@jqmp

Description

@jqmp

Sometimes users pass a single argument to @bn.outputs, expecting it to work like @bn.output:

builder = bn.FlowBuilder('test')

@builder
@bn.outputs('value')
def _():
    return 7

flow = builder.build()

flow.get('value')

This fails because @outputs expects the decorated function to return a sequence with one value. The correct thing would be to either return the tuple 7,, or use @bn.output instead of @bn.outputs. However, the error message could be more helpful:

EntityValueError: Value received for '<value>,' is not valid for TupleProtocol due to <class 'AssertionError'>: 'int' object is not iterable

The message is correct, but it would be better to state what was expected (a sequence of length 1). We could even go farther and say something like "did you mean to use @output instead of @outputs?". (Also, we should probably replace the <class 'AssertionError'> with just AssertionError.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions