fix: actionable error when --password-file or --token-file is missing (#289)#412
Open
jacalata wants to merge 3 commits into
Open
fix: actionable error when --password-file or --token-file is missing (#289)#412jacalata wants to merge 3 commits into
jacalata wants to merge 3 commits into
Conversation
…is missing Previously, a non-existent path caused a bare FileNotFoundError traceback. Now tabcmd exits with a clear message pointing to the bad argument. Closes #289 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…le errors
- Replace os.path.exists with os.path.isfile so directories are rejected cleanly
- Replace hard-coded English error strings with localized keys
session.errors.password_file_not_found and session.errors.token_file_not_found
- Add those two keys to tabcmd_messages_en.properties and rebuild the .mo file
- Move file-not-found tests into a dedicated MissingCredentialFileTests class;
configure mock_path.isfile.return_value = False so the guard is actually hit
(the class-level @mock.patch("os.path") replaces the whole module, so setting
the isfile attribute directly on the mock is the correct approach)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…sert message content Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
Summary
os.path.isfile()before opening--password-file/--token-file; exits with a message containing the bad path rather than a rawFileNotFoundErrortracebackopen()in try/except IOError so permission errors also produce a friendly messageNonewould fall through to a generic error)session.errors.password_file_not_foundandsession.errors.token_file_not_foundos.pathmock madeisfile()return truthy MagicMock) with correctly-scoped patchescreate_session()asserting the i18n key or translated message appears in the errorTest plan
python -m pytest tests/commands/test_session.py -v— all 50 tests passtabcmd login --password-file /nonexistent/path.txt— exits with message containing the pathtabcmd login --token-file /nonexistent/token.txt— exits with message containing the path🤖 Generated with Claude Code