#How do accept error codes >127 from containers?

1 messages · Page 1 of 1 (latest)

narrow bay
#

Basically what the title says. Sometimes, some stuff returns exit codes greater than 127. I'd like to not shell wrap if possible. Outside of wrapping in a shell and grepping in the wrap, how could I execute a command that can fail with err code >127?

Min repro example: I tried to use an aws-cli container to see if a specific image tag existed. If ReturnType.ANY truly was ANY, I'd expect this to work as written but it doesn't. AWS CLI returns err code 254 for this function if no such image exists:

    @function
    async def test_ecr_check_pattern(
        self,
        aws_config_dir: Annotated[dagger.Directory, Doc("AWS config dir (~/.aws)")],
    ) -> str:
        """Reproduce the exact ECR check pattern to see if it fails.

        This mimics check_ecr_image_exists() but for a non-existent image.
        """
        container = dag.container().from_("amazon/aws-cli:latest")
        container = container.with_mounted_directory("/root/.aws", aws_config_dir)
        container = container.with_env_variable("AWS_REGION", "us-east-1")

        # Check for a non-existent image - this SHOULD fail but not throw
        result = await container.with_exec(
            [
                "aws",
                "ecr",
                "describe-images",
                "--repository-name",
                "some_repo_of_mine",
                "--image-ids",
                "imageTag=this-tag-does-not-exist-12345",
                "--region",
                "us-east-1",  # I <3 downtime
            ],
            expect=dagger.ReturnType.ANY,
        ).sync()

        exit_code = await result.exit_code()
        return f"ECR check exited with code: {exit_code} (0=exists, non-zero=not found)"

Using dagger 0.19.8

#

And from dagger_gen.py:

class ReturnType(Enum):
    """Expected return type of an execution"""

    ANY = 'ANY'
    """Any execution (exit codes 0-127)"""

    FAILURE = 'FAILURE'
    """A failed execution (exit codes 1-127)"""

    SUCCESS = 'SUCCESS'
    """A successful execution (exit code 0)"""
mossy roost
#

@narrow bay at the moment it's not possible... Because some exit codes above 127 are special signal-triggered termination codes , and that has caching implications...

But it looks like it would be safe to allow >192.

Would you mind opening an issue? 🙏