fix(workflows): gate prompt uses isdecimal() so a superscript digit can't crash it#3624
Merged
Merged
Conversation
…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>
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes the interactive gate prompt crashing on Unicode digits unsupported by int().
Changes:
- Replaces
isdigit()withisdecimal()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
Collaborator
|
Thank you! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The interactive
gatestep prompt parses a numeric choice like this:str.isdigit()returnsTruefor charactersint()rejects — e.g. the superscript²('²'.isdigit()isTrue, butint('²')raisesValueError). So entering²at the prompt passes the guard and then crashes the input loop with an uncaughtValueError.Fix
Use
raw.isdecimal()— exactly the decimal-digit setint()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²then1returns 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.