fix: Avoid re-login when set mode to interactive - #86
Merged
aviatco merged 12 commits intoDec 24, 2025
Conversation
added 2 commits
December 23, 2025 11:11
…de' of https://github.com/microsoft/fabric-cli into dev/aviatcohen/avoidReLoginWhenSwitchingToInteractiveMode
Alon Yeshurun (ayeshurun)
approved these changes
Dec 23, 2025
aviatco
deleted the
dev/aviatcohen/avoidReLoginWhenSwitchingToInteractiveMode
branch
December 24, 2025 07:41
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.
📥 Pull Request
✨ Description of new changes
🎯 Overview
This PR enhances the user experience by eliminating the need to re-authenticate when switching from command-line mode to interactive mode using fab config set mode interactive. Previously, users had to manually run fab auth login after setting the mode, creating friction in the workflow.
🔧 Changes Made
Enhanced parser reusability: Extracted _create_parser_and_subparsers() function to enable parser reuse across different contexts
Improved auth flow: Streamlined the authentication and mode transition logic in the main entry point
Smart authentication check: Added _is_user_authenticated() function that validates existing tokens without requiring interactive renewal
Seamless mode transition: Enhanced mode switching logic in _set_config() to automatically launch interactive mode when:
Switching from command-line to interactive mode
User has valid authentication tokens
Automatic interactive launch: Added _start_interactive_mode() function that reuses existing parser context to launch interactive mode
Graceful fallback: If user is not authenticated, provides clear guidance to login first
🚀 User Experience Improvements
$ fab config set mode interactive
Configuration 'mode' set to 'interactive'
Switching to interactive mode...
Welcome to the Fabric CLI ⚡
fab:/$
🔐 Security Considerations
Token validation is performed without triggering interactive authentication flows
Existing authentication patterns and security boundaries are preserved
Falls back to requiring explicit login if tokens are invalid or expired
🧪 Technical Details
Authentication validation: Uses FabAuth.get_access_token() with interactive_renew=False to check token validity
Parser reuse: Leverages the extracted parser creation function to maintain consistency between command-line and interactive contexts
Error handling: Graceful handling of authentication errors and interactive mode failures
Context management: Proper cleanup of context files during mode transitions
✅ Impact
Improved UX: Eliminates unnecessary authentication steps
Workflow efficiency: Reduces friction when switching between modes
Backward compatibility: Maintains existing behavior for unauthenticated users
Code reusability: Extracted parser creation logic for better maintainability