Skip to content

fix(workflows): gate prompt uses isdecimal() so a superscript digit can't crash it#3624

Merged
mnriem merged 1 commit into
github:mainfrom
jawwad-ali:fix/gate-prompt-isdecimal
Jul 22, 2026
Merged

fix(workflows): gate prompt uses isdecimal() so a superscript digit can't crash it#3624
mnriem merged 1 commit into
github:mainfrom
jawwad-ali:fix/gate-prompt-isdecimal

Conversation

@jawwad-ali

Copy link
Copy Markdown
Contributor

What

The interactive gate step prompt parses a numeric choice like this:

if raw.isdigit() and 1 <= int(raw) <= len(options):

str.isdigit() returns True for characters int() rejects — e.g. the superscript ² ('²'.isdigit() is True, but int('²') raises ValueError). So entering ² at the prompt passes the guard and then crashes the input loop with an uncaught ValueError.

Fix

Use raw.isdecimal() — exactly the decimal-digit set int() accepts (Numeric_Type=Decimal), which excludes superscripts/subscripts while preserving every real decimal digit across scripts. Such input is now treated as an invalid choice and re-prompted. No behavior change for valid input.

Test

test_interactive_prompt_rejects_non_decimal_digit: input ² then 1 returns the first option — fails before (ValueError), passes after.


🤖 Written with the assistance of Claude Code (AI). Bug self-found; fix/tests verified locally (fail-before / pass-after), ruff clean.

…oesn't crash

The interactive gate prompt guarded numeric choices with raw.isdigit(), but
str.isdigit() returns True for characters int() rejects — superscripts/subscripts
like '²'. So typing '²' passed the guard and int('²') raised an uncaught
ValueError, crashing the prompt loop. Use raw.isdecimal(), which is exactly the
decimal-digit set int() accepts (Numeric_Type=Decimal), so such input is treated
as an invalid choice and re-prompted. No behavior change for valid input.

Test: input '²' then '1' returns the first option (fails before: ValueError).

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

Copilot AI 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.

Pull request overview

Fixes the interactive gate prompt crashing on Unicode digits unsupported by int().

Changes:

  • Replaces isdigit() with isdecimal() for numeric choices.
  • Adds regression coverage for superscript digit input.
Show a summary per file
File Description
src/specify_cli/workflows/steps/gate/__init__.py Safely validates decimal input.
tests/test_workflows.py Tests invalid Unicode digit handling.

Review details

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Medium

@mnriem
mnriem merged commit 9ef4771 into github:main Jul 22, 2026
12 checks passed
@mnriem

mnriem commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

Thank you!

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