#Cannot have a Dagger Enum as the default value in a Function?

1 messages · Page 1 of 1 (latest)

knotty mountain
#

I'd appreciate some clarification on an issue I'm facing right now.
I have an Enum defined like:

@dagger.enum_type
class Env(dagger.Enum):
    """
    Environment the project will be run in
    """

    DEV = 'DEV', 'foo'
    INT = 'INT', 'foo'
    TEST = (
        'TEST',
        'foo',
    )

( I've shortened the descriptions )
I'm trying to have the default arguments like:

@function
    async def test_func(
        self,
        src: Annotated[dagger.Directory, Doc('Project root directory')],
        env: Env = Env.DEV,
    ) -> SomeCustomType

but whenever I call the test_func without specifying env I get an error like:
Error: response from query: input: workspace.testFunc resolve: failed to convert arg "env": invalid enum value "".
I started running into this today, I could swear it worked like expected a day or two ago.
I'm running dagger version 0.12.

Is this simply not possible or am I missing something?

knotty mountain
#

I've upgraded to 0.12.1 and still get it.

knotty mountain
#

Perhaps it's not possible after all? Default values for other types such as str work as expected, and they show up when calling --help too.

old vortex
#

Hey @knotty mountain, it should be possible. I'll investigate, thanks! It would be helpful if you could create a GH issue for that so you can track progress.

old vortex
old vortex
#

Hey @knotty mountain, the fix was released in v0.12.2 already.

GitHub

v0.12.2 - 2024-07-22
Changed

dagger init now generates files in the current directory by default and no longer in ./dagger by @TomChv in #7824

Fixed

cli: fix handling of enum default values by @...