Skip to content

Drop order in ConfigWorld may reintroduce environment variable unexpectedly #126

Description

@coderabbitai

Context

In tests/steps/config_steps.rs at line 136, the Drop implementation for ConfigWorld releases env_guard before socket_guard:

impl Drop for ConfigWorld {
    fn drop(&mut self) {
        if let Some(_guard) = self.env_guard.take() {
            // dropping the guard restores the previous state
        }
        if let Some(_guard) = self.socket_guard.take() {
            // dropping the guard restores the previous state
        }
    }
}

Issue

If a future scenario sets COMENQD_SOCKET_PATH before calling config_file_with_token, the current drop order could reintroduce the environment variable on drop, leading to unexpected test behaviour.

Recommendation

Consider dropping socket_guard first or consolidating guards for the same key to avoid ordering surprises.

References

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions