Skip to content
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

[BUG] TypeError: can't convert null to object if using wrong default in dataclass #3157

Closed
2 tasks done
fellhorn opened this issue Dec 15, 2022 · 1 comment · Fixed by flyteorg/flyteconsole#693
Closed
2 tasks done
Assignees
Labels
bug Something isn't working ui Admin console user interface
Milestone

Comments

@fellhorn
Copy link
Contributor

fellhorn commented Dec 15, 2022

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:

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:

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

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:

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
@fellhorn fellhorn added bug Something isn't working untriaged This issues has not yet been looked at by the Maintainers labels Dec 15, 2022
@welcome
Copy link

welcome bot commented Dec 15, 2022

Thank you for opening your first issue here! 🛠

@eapolinario eapolinario self-assigned this Dec 16, 2022
@cosmicBboy cosmicBboy added ui Admin console user interface and removed untriaged This issues has not yet been looked at by the Maintainers labels Feb 6, 2023
@cosmicBboy cosmicBboy added this to the 1.4.0 milestone Feb 6, 2023
@jsonporter jsonporter assigned 4nalog and unassigned jsonporter Mar 1, 2023
@cosmicBboy cosmicBboy modified the milestones: 1.4.0, 1.5.0 Mar 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ui Admin console user interface
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants