Skip to content

feat: convert None to empty string and validate action parameter type in step() method - #170

Open
KempinskiB wants to merge 2 commits into
TextArena:mainfrom
KempinskiB:secret-mafia-bugfix
Open

feat: convert None to empty string and validate action parameter type in step() method#170
KempinskiB wants to merge 2 commits into
TextArena:mainfrom
KempinskiB:secret-mafia-bugfix

Conversation

@KempinskiB

Copy link
Copy Markdown
Contributor

No description provided.

@bobbycxy

bobbycxy commented Oct 7, 2025

Copy link
Copy Markdown
Collaborator

Hey Ben, sorry could you share what's the issue? Generally, if no action is provided, the environment returned is still a "str" class.

@borgr

borgr commented Aug 8, 2026

Copy link
Copy Markdown
Collaborator

Recommend merge. Two independent changes, both safe:

  1. Assert-message fix (genuine correctness): the check is assert 6 <= num_players <= 15 but the message read "between 5 and 15". A user passing num_players=5 would get an error message telling them 5 is allowed. This is unambiguously worth fixing on its own.

  2. step() input guard (harmless defensive validation): to @bobbycxy's question — you're right that on the normal path action is already a str, so this is a no-op for real gameplay. It only adds a graceful None → "" coercion and a clear TypeError for a non-str/non-None arg, instead of failing later with a more confusing error deeper in _handle_*. Nothing about the str path changes, so there's no behavioral risk either way.

Given (1) is a real fix and (2) is harmless, this is fine to merge. Only nit: there's a trailing-whitespace blank line inside the new guard block — worth stripping before merge, but not a blocker.

@borgr

borgr commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

Verified. The assert-message correction is unambiguously right — the guard is assert 6 <= num_players <= 15, so the old "between 5 and 15" text was wrong; "between 6 and 15" now matches. Optional is already imported, so the Optional[str] signature is fine.

The None → "" / TypeError handling in step() is reasonable defensive input-validation and doesn't change behavior for valid callers. Two small optional nits if you're tidying before merge: the inserted blank line carries trailing whitespace, and the type-check is arguably more than the surrounding envs do — happy either way.

Core fix LGTM, recommend merge.

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.

3 participants