Skip to content

Conversation

@hovu96
Copy link
Contributor

@hovu96 hovu96 commented Oct 27, 2025

Summary

Fixed the project detection logic in workato init to check for existing projects AFTER the user selects which project they want to initialize, rather than prematurely prompting based on any .workatoenv in the current directory.

Problem

The old behavior would check for any .workatoenv file in the current directory BEFORE the user selected which project they wanted to initialize. This caused confusion when users had old project files from previous initializations that were unrelated to what they wanted to initialize.

Solution

  • Removed premature check that looked for .workatoenv before user selection
  • Added proper check after project selection using _find_all_projects()
  • Detection now matches by project_id across entire workspace
  • Interactive mode prompts for reinitialization if project exists
  • Non-interactive mode fails with clear error if project exists
  • Corrupted configs are gracefully skipped during detection

Changes Made

Files Modified

  • src/workato_platform/cli/utils/config/manager.py

    • Removed lines 346-380 (premature check in _setup_project())
    • Added proper detection after project selection in both interactive and non-interactive modes
    • Detection uses _find_all_projects() and matches by project_id
  • tests/unit/config/test_manager.py

    • Added 6 new comprehensive tests
    • Removed 3 obsolete tests testing old behavior
    • Fixed 1 existing test to work with new behavior

Test Coverage

Added comprehensive test coverage (6 new tests):

  • No premature prompts with old .workatoenv files
  • Detection after user selection
  • User declining reinitialization
  • Non-interactive mode error handling
  • Corrupted config handling
  • Matching by project_id instead of name

Test Results: All 899 tests passing

Quality Checks

✅ All type checks pass (mypy)
✅ All linter checks pass (ruff)
✅ Code properly formatted
✅ 96% test coverage on modified code
✅ All 899 tests passing

🤖 Generated with Claude Code

Changed the project detection logic in workato init to check for existing
projects AFTER the user selects which project they want to initialize,
rather than prematurely prompting based on any .workatoenv in the current
directory.

Key changes:
- Removed premature check that looked for .workatoenv before user selection
- Added proper check after project selection using _find_all_projects()
- Detection now matches by project_id across entire workspace
- Interactive mode prompts for reinitialization if project exists
- Non-interactive mode fails with clear error if project exists
- Corrupted configs are gracefully skipped during detection

Added comprehensive test coverage (6 new tests) for:
- No premature prompts with old .workatoenv files
- Detection after user selection
- User declining reinitialization
- Non-interactive mode error handling
- Corrupted config handling
- Matching by project_id instead of name

All 899 tests passing.

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

Co-Authored-By: Claude <noreply@anthropic.com>
@github-actions
Copy link

Coverage

Coverage Report
FileStmtsMissCoverMissing
__init__.py62296%12–13
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%578, 580, 586, 624, 973
   data_tables.py163596%28, 248, 262, 316–317
   guide.py166199%106
   init.py850100% 
   profiles.py1970100% 
   properties.py95198%18
   pull.py171298%190–191
   workspace.py38294%57, 67
cli/commands/connectors
   __init__.py00100% 
   command.py88297%103, 152
   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%101, 104, 222, 300
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% 
TOTAL544613297% 

@hovu96 hovu96 self-assigned this Oct 27, 2025
@hovu96 hovu96 requested a review from oalami October 27, 2025 11:55
@oalami oalami requested a review from Copilot October 27, 2025 19:34
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

Fixed workato init to detect existing projects after user selection instead of prematurely checking for .workatoenv files before the user chooses which project to initialize. This prevents confusion when old project files exist in the current directory that are unrelated to the project being initialized.

Key changes:

  • Removed premature project detection check that occurred before user selection
  • Added proper detection logic after project selection using _find_all_projects() and matching by project_id
  • Enhanced error handling for both interactive and non-interactive modes when projects already exist

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/workato_platform/cli/utils/config/manager.py Removed premature detection logic (lines 346-380), added post-selection detection in both _setup_project() and _setup_non_interactive() methods
tests/unit/config/test_manager.py Removed 3 obsolete tests for old behavior, added 6 comprehensive tests for new detection logic, updated 1 existing test to work with new flow

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

@hovu96 hovu96 merged commit 17c03fe into main Oct 28, 2025
5 checks passed
@hovu96 hovu96 deleted the workato-init-incorrectly-detects-existing-project-instead-of-initializing-a-new-one branch October 28, 2025 07:39
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