Skip to content

Conversation

@oalami
Copy link
Collaborator

@oalami oalami commented Oct 31, 2025

I have run into issues pasting long length (750+char) API keys - it appears that it is getting truncated.

I believe this is caused by terminal emulator input buffer limitations, not the pwinput library itself. The pwinput library processes input character-by-character using getch(), which makes it vulnerable to terminal paste buffer limits.

Lets push this improvement out to a later release.

Reverts #28

Copilot AI review requested due to automatic review settings October 31, 2025 18:16
@github-actions
Copy link

Coverage

Coverage Report
FileStmtsMissCoverMissing
__init__.py68494%10–11, 69–70
cli
   __init__.py52394%49, 51, 60
   containers.py270100% 
cli/commands
   __init__.py00100% 
   api_clients.py286996%24, 297, 442–443, 476, 486, 576, 607, 615
   api_collections.py253398%25, 178, 340
   assets.py46295%51–52
   connections.py520599%582, 584, 590, 628, 977
   data_tables.py163596%28, 248, 262, 316–317
   guide.py166199%106
   init.py890100% 
   profiles.py1970100% 
   properties.py95198%18
   pull.py171298%190–191
   workspace.py38294%57, 67
cli/commands/connectors
   __init__.py00100% 
   command.py88297%105, 154
   connector_manager.py203498%176, 292, 300–301
cli/commands/projects
   __init__.py00100% 
   command.py2691096%353–356, 367, 433–435, 485, 489
   project_manager.py166795%48, 66, 263–264, 276, 317, 325
cli/commands/push
   __init__.py00100% 
   command.py132496%105, 108, 226, 304
cli/commands/recipes
   __init__.py00100% 
   command.py423997%113, 129–130, 267–270, 397, 703
   validator.py7062097%174, 883, 1136, 1223, 1246, 1279, 1281–1282, 1359–1361, 1457–1458, 1517–1518, 1707–1708, 1736–1738
cli/utils
   __init__.py30100% 
   exception_handler.py198696%137, 184, 211, 238, 295, 330
   gitignore.py140100% 
   ignore_patterns.py230100% 
   spinner.py430100% 
   version_checker.py135695%24, 26, 33–34, 72, 102
cli/utils/config
   __init__.py50100% 
   manager.py4671995%125, 136–138, 141, 154, 204–205, 357, 438–439, 478, 692, 835–836, 850–851, 912, 971
   models.py330100% 
   profiles.py3091096%93, 189–190, 193, 228–230, 255–257
   workspace.py680100% 
TOTAL545613497% 

@oalami oalami requested a review from cmworkato October 31, 2025 18:17
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR removes the pwinput dependency and replaces it with asyncclick's built-in hide_input parameter for secure token input. The change simplifies the dependency footprint by using functionality already available in the asyncclick library.

  • Replaced pwinput.pwinput() with click.prompt(..., hide_input=True) for API token input
  • Removed pwinput dependency from all configuration files
  • Updated test mocks to use click.prompt instead of pwinput.pwinput

Reviewed Changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/workato_platform_cli/cli/utils/config/manager.py Replaced pwinput import and usage with asyncclick's hide_input parameter, removed explanatory comments about pwinput behavior
tests/unit/config/test_manager.py Updated test mocks to use click.prompt instead of pwinput.pwinput, added token prompts to test prompt_answers dictionaries
pyproject.toml Removed pwinput dependency specification and mypy ignore configuration
uv.lock Removed pwinput package definition and references
.pre-commit-config.yaml Removed pwinput from additional dependencies list

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

@cmworkato
Copy link
Collaborator

Approved.

cmworkato
cmworkato approved these changes Oct 31, 2025
@cmworkato cmworkato merged commit d0788bd into main Oct 31, 2025
11 checks passed
@cmworkato cmworkato deleted the revert-28-enhancement/masked-token-input branch October 31, 2025 18:28
hovu96 added a commit that referenced this pull request Nov 5, 2025
Implements a new token input utility that provides visual feedback
for API token entry with intelligent paste detection:

- Shows asterisks (****) for manually typed characters
- Detects long paste operations (>50 chars) via bracketed paste mode
- Displays inline confirmation with character count in gray text
- Combines typed and pasted content seamlessly
- Handles very long tokens (750+ chars) without truncation
- Avoids terminal buffer limitations of character-by-character input

Technical Implementation:
- Uses prompt_toolkit for password input with bracketed paste support
- Custom key bindings to detect and handle paste events
- ANSI escape sequences for inline confirmation prompt
- Proper error handling and retry logic

Dependencies:
- Added prompt-toolkit>=3.0.0
- Updated mypy configuration and pre-commit hooks

Testing:
- 13 comprehensive unit tests with 61% code coverage
- Tests cover typing, pasting, confirmation, retries, and error cases
- All tests pass with proper mocking of terminal interaction

Related to PR #28 (reverted in #29 due to pwinput truncation issues)
This solution resolves the truncation problem by using bracketed paste
mode instead of character-by-character input processing.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
oalami added a commit that referenced this pull request Nov 6, 2025
* feat: Add smart token input with bracketed paste detection

Implements a new token input utility that provides visual feedback
for API token entry with intelligent paste detection:

- Shows asterisks (****) for manually typed characters
- Detects long paste operations (>50 chars) via bracketed paste mode
- Displays inline confirmation with character count in gray text
- Combines typed and pasted content seamlessly
- Handles very long tokens (750+ chars) without truncation
- Avoids terminal buffer limitations of character-by-character input

Technical Implementation:
- Uses prompt_toolkit for password input with bracketed paste support
- Custom key bindings to detect and handle paste events
- ANSI escape sequences for inline confirmation prompt
- Proper error handling and retry logic

Dependencies:
- Added prompt-toolkit>=3.0.0
- Updated mypy configuration and pre-commit hooks

Testing:
- 13 comprehensive unit tests with 61% code coverage
- Tests cover typing, pasting, confirmation, retries, and error cases
- All tests pass with proper mocking of terminal interaction

Related to PR #28 (reverted in #29 due to pwinput truncation issues)
This solution resolves the truncation problem by using bracketed paste
mode instead of character-by-character input processing.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* feat: Integrate smart token input into workato init command

Replaced click.prompt with get_token_with_smart_paste utility in both
token prompt locations (_create_profile_with_env_vars and _create_new_profile).
This provides visual feedback (asterisk masking) and handles long token
pastes without truncation.

Changes:
- Added asyncio import and get_token_with_smart_paste import to manager.py
- Replaced token prompts with asyncio.to_thread(get_token_with_smart_paste)
- Updated 4 tests to mock get_token_with_smart_paste instead of click.prompt

All 944 tests passing. Type checking, linting, and formatting all pass.

Fixes DEVP-498

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Update src/workato_platform_cli/cli/utils/config/manager.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update src/workato_platform_cli/cli/utils/token_input.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* refactor: replace sys.exit with ClickException for proper error handling

- Remove try-except wrapper in _prompt_and_validate_credentials that was
  masking UnauthorizedException, preventing proper error handling
- Replace all sys.exit(1) calls with click.ClickException for validation
  errors and user cancellations
- Remove unused sys import
- Update tests to expect click.ClickException instead of SystemExit

This allows @handle_api_exceptions and @handle_cli_exceptions decorators
to properly catch and format all errors consistently.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* refactor: standardize token error messages for consistency

- Change "No token provided" to "API token cannot be empty" for consistency
- Change prompt_text from "Workato API token" to "API token" (context is
  already clear from CLI name)
- Update token_input.py to dynamically use prompt_text in error messages
  instead of hardcoded "Token"
- Update tests to expect new consistent messaging

All token-related error messages now consistently use "API token" across
the codebase.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Ossama Alami <ossama.alami@workato.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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