<#3157 [BUG] TypeError: can't convert null to obje...
# flyte-github
a
#3157 [BUG] TypeError: can't convert null to object if using wrong default in dataclass Issue created by fellhorn Describe the bug When trying to launch a workflow with a faulty
dataclass
the UI breaks with an unhelpful react error as shown in the screenshot:
Copy code
The error we received was:
TypeError: can't convert null to object

There may be additional information in the browser console.
Please find this minimal example workflow:
Copy code
from typing import Optional, Dict

from dataclasses import dataclass
from dataclasses_json import dataclass_json
from flytekit import task, workflow


@dataclass_json
@dataclass
class MyConfig:
    k: Optional[Dict] = None


@task
def t1(a: MyConfig) -> str:
    if a.k and "foo" in a.k:
        return a.k["foo"]
    else:
        return "42"


@workflow
def my_wf(a: MyConfig = MyConfig()) -> str:
    x = t1(a=a)
    return x
where
k
has a wrong default. Instead of
k: Optional[Dict] = None
, it should be
Copy code
from dataclasses import field

@dataclass_json
@dataclass
class MyConfig:
    k: Optional[Dict] = field(default_factory=lambda: {})
Expected behavior I am aware of the error on the user side. Still: I think flyte could show a more helpful error message here to point to the bad parameter. Additional context to reproduce The error shown in the browser dev console is:
Copy code
TypeError: can't convert null to object
**REDACTED**
 
Object { componentStack: "\n    in Unknown\n    in div\n    in S\n    in section\n    in ForwardRef\n    in div\n    in ForwardRef\n    in ForwardRef\n    in Unknown\n    in Unknown\n    in div\n    in ForwardRef\n    in ForwardRef\n    in div\n    in t\n    in ForwardRef\n    in s\n    in div\n    in ForwardRef\n    in ForwardRef\n    in ForwardRef\n    in ForwardRef\n    in Unknown\n    in E\n    in Unknown\n    in Unknown\n    in Unknown\n    in E\n    in div\n    in Unknown\n    in Unknown\n    in t\n    in t\n    in Unknown\n    in E\n    in t\n    in div\n    in t\n    in Unknown\n    in l\n    in c\n    in l\n    in Unknown\n    in Unknown\n    in Unknown" }
main-965d5331.js:1:369655
Screenshots

image

Are you sure this issue hasn't been raised already? ☑︎ Yes Have you read the Code of Conduct? ☑︎ Yes flyteorg/flyte