Skip to content

Raise error when using container has not been executed - #4716

Merged
vito merged 3 commits into
dagger:mainfrom
vito:err-on-no-exec
Mar 7, 2023
Merged

vito merged 3 commits into
dagger:mainfrom
vito:err-on-no-exec

Conversation

@vito

@vito vito commented Mar 6, 2023

Copy link
Copy Markdown
Contributor

Previously exitCode, stdout, and stderr would simply return null if a container had not been executed yet, i.e. a container that's really just an image. Worse, this would actually get turned into the zero-value for each in the Go SDK (0, "") making it look like a successful exec.

Additionally, it was easy to accidentally use an un-exec'd container as a service, e.g. by running an off-the-shelf redis or postgres image without including WithExec(nil). You'd get a weird error with an empty hostname.

Now in all cases we'll raise an error when trying to use a container that has never exec'd.

fixes #4668

@vito
vito requested review from helderco and shykes March 6, 2023 23:50
@vito vito changed the title raise error when container has not been executed Raise error when using container has not been executed Mar 6, 2023

@helderco helderco left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

Running example in #4668 ends in:

panic: input:1: container.build.exitCode no command has been executed

Please visit https://dagger.io/help#go for troubleshooting guidance.

...
exit status 2

vito added 3 commits March 7, 2023 13:48
Previously exitCode, stdout, and stderr would simply return null if a
container had not been executed yet, i.e. a container that's really just
an image. Worse, this would actually get turned into the zero-value for
each in the Go SDK (0, "", "") making it look like a successful exec.

Additionally, it was easy to accidentally use an un-exec'd container as
a service, e.g. by running an off-the-shelf redis or postgres image.
You'd get a weird error with an empty hostname.

Now in all cases we'll raise an error when trying to use a container
that has never exec'd.

Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
@vito
vito force-pushed the err-on-no-exec branch from e34cb55 to 33bf1dc Compare March 7, 2023 18:48
@vito

vito commented Mar 7, 2023

Copy link
Copy Markdown
Contributor Author

Merging optimistically, but leaving the door open for more bikeshedding later. I think this is a net benefit with services around the corner. I just ran into this gotcha while working on my own demo and the error let me figure it out pretty quickly (obvious caveat that I'm the one that added it, but it's strictly better than no error).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Lazy executions are confusing to understand and sometimes don't work as expected

2 participants