Skip to content

fix: don't pass a message when converting an unknown status by name - #2700

Merged
tonyandrewmeyer merged 4 commits into
canonical:mainfrom
tonyandrewmeyer:fix-unknownstatus-from-ops
Aug 24, 2026
Merged

fix: don't pass a message when converting an unknown status by name#2700
tonyandrewmeyer merged 4 commits into
canonical:mainfrom
tonyandrewmeyer:fix-unknownstatus-from-ops

Conversation

@tonyandrewmeyer

Copy link
Copy Markdown
Collaborator

_EntityStatus.from_status_name('unknown', ...) tried to construct UnknownStatus(message=...), but UnknownStatus.init takes no arguments, so any round trip through from_ops() (e.g. _EntityStatus.from_ops(some_status._to_ops())) raised a TypeError.

Special-case 'unknown' in from_status_name to construct UnknownStatus() directly, mirroring ops.StatusBase.from_name, which already documents and implements this same special case: unknown status has no message to preserve. The other status types all accept a message, so no other special-casing is needed.

In Ops you wouldn't create an Unknown status, because you can't set it. But in Scenario you might create one to indicate a starting status.

claude and others added 3 commits August 21, 2026 19:07
_EntityStatus.from_status_name('unknown', ...) tried to construct
UnknownStatus(message=...), but UnknownStatus.__init__ takes no
arguments, so any round trip through from_ops() (e.g.
_EntityStatus.from_ops(some_status._to_ops())) raised a TypeError.

Special-case 'unknown' in from_status_name to construct UnknownStatus()
directly, mirroring ops.StatusBase.from_name, which already documents
and implements this same special case: unknown status has no message
to preserve. The other status types all accept a message, so no other
special-casing is needed.
The round-trip test imported _EntityStatus inside the test body; the
module already imports the other names it needs from scenario.state, so
move it up to join them.
@tonyandrewmeyer
tonyandrewmeyer marked this pull request as ready for review August 24, 2026 02:44

@james-garner-canonical james-garner-canonical 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.

I assume that this from_status_name is public since its exposed on the scenario version of the error status objects. So I wonder if we should take this opportunity to consider making passing a name='unknown', message='not an empty string' an error or warning.

Comment thread testing/src/scenario/state.py Outdated
Comment thread testing/tests/test_e2e/test_status.py
`from_status_name` silently dropped `message` when `name` was 'unknown'.
Warn instead, document the behaviour in the docstring, and cover both
`from_status_name` and the unknown-with-message case in the tests.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

@james-garner-canonical james-garner-canonical 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.

Good catch here. Thanks for addressing my feedback!

@tromai tromai 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.

Thank you for the fix.

I agree with: warning when unknown status is created with a non-empty message.

@tonyandrewmeyer
tonyandrewmeyer merged commit dd37d3c into canonical:main Aug 24, 2026
60 checks passed
@tonyandrewmeyer
tonyandrewmeyer deleted the fix-unknownstatus-from-ops branch August 24, 2026 05:51
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.

4 participants