Skip to content

Include container status to IncorrectStatus error messaging#3411

Open
CarloQuick wants to merge 2 commits intoyouki-dev:mainfrom
CarloQuick:feat/incorrect-status-error
Open

Include container status to IncorrectStatus error messaging#3411
CarloQuick wants to merge 2 commits intoyouki-dev:mainfrom
CarloQuick:feat/incorrect-status-error

Conversation

@CarloQuick
Copy link

Description

IncorrectStatus was using generic error message, so I included ContainerStatus to the IncorrectStatus error variant.

// Before
Caused by:
failed to perform operation due to incorrect container status

// After
Caused by:
failed to perform operation due to the container's status: `Running`

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Performance improvement
  • Test updates
  • CI/CD related changes
  • Other (please describe):

Testing

  • Added new unit tests

  • Added new integration tests

  • Ran existing test suite

  • Tested manually (please provide steps)

  • Added unit test: test_libcontainer_error_msg to verify correct formatting and display of each container status in the error messaging.

  • Ran existing test suite: Ran libcontainer tests locally with cargo test -p libcontainer,
    tty::tests::test_setup_console and tty::tests::test_verify_ptmx_handle_with_real_pty fail locally. (These appear to be pre-existing environment-specific failures (devpts on WSL2), unrelated to this change.)

  • Tested manually: I created a container, and while running attempted to delete it without the force flag. The displayed error message contained the container's status.

Related Issues

Fixes #3410

Additional Context

n/a

@utam0k utam0k added the kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. label Feb 17, 2026
@CarloQuick CarloQuick marked this pull request as ready for review February 17, 2026 11:10
pub enum LibcontainerError {
#[error("failed to perform operation due to incorrect container status")]
IncorrectStatus,
#[error("failed to perform operation due to the container's status: `{0}`")]
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit:

Suggested change
#[error("failed to perform operation due to the container's status: `{0}`")]
#[error("failed to perform operation due to unexpected container status: `{0}`")]

My reasoning is that the error message should have some indication that this status was not correct/expected. Previously, we used to say incorrect status.

However, not a blocker, but like to hear opinion.

Copy link
Author

Choose a reason for hiding this comment

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

This makes sense.

The operation being requested is wrong for the status.

What are your thoughts the following?

failed operation due to incompatible container status: `Running`

Copy link
Member

Choose a reason for hiding this comment

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

LGTM

Copy link
Author

Choose a reason for hiding this comment

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

@utam0k are you referring to suggested wording, correct?

Copy link
Member

Choose a reason for hiding this comment

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

Right.

Copy link
Author

Choose a reason for hiding this comment

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

@utam0k @YJDoc2
Thank you both for your feedback. I've fixed the message wording here: ce81de3

Signed-off-by: Carlo Quick <98628846+CarloQuick@users.noreply.github.com>
@CarloQuick CarloQuick force-pushed the feat/incorrect-status-error branch from b4977be to aaa00d9 Compare February 19, 2026 22:52
Signed-off-by: Carlo Quick <98628846+CarloQuick@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IncorrectStatus error should include container status

3 participants

Comments