Skip to content

fix: actionable error when --password-file or --token-file is missing (#289)#412

Merged
bcantoni merged 4 commits into
developmentfrom
jac/fix-289-missing-credentials-error
Jul 20, 2026
Merged

fix: actionable error when --password-file or --token-file is missing (#289)#412
bcantoni merged 4 commits into
developmentfrom
jac/fix-289-missing-credentials-error

Conversation

@jacalata

@jacalata jacalata commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Fixes Add useful error messages about missing password/token file in login #289
  • Checks os.path.isfile() before opening --password-file / --token-file; exits with a message containing the bad path rather than a raw FileNotFoundError traceback
  • Wraps open() in try/except IOError so permission errors also produce a friendly message
  • Guards against empty credential files (silent None would fall through to a generic error)
  • Adds localized error keys session.errors.password_file_not_found and session.errors.token_file_not_found
  • Replaces tests that didn't exercise the code path (global os.path mock made isfile() return truthy MagicMock) with correctly-scoped patches
  • Adds end-to-end tests through create_session() asserting the i18n key or translated message appears in the error

Test plan

  • python -m pytest tests/commands/test_session.py -v — all 50 tests pass
  • tabcmd login --password-file /nonexistent/path.txt — exits with message containing the path
  • tabcmd login --token-file /nonexistent/token.txt — exits with message containing the path

🤖 Generated with Claude Code

jacalata and others added 3 commits July 1, 2026 18:17
…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>
@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown

Coverage

Coverage Report
FileStmtsMissCoverMissing
tabcmd
   __main__.py121212 0%
   _version.py111111 0%
   tabcmd.py151515 0%
   version.py955 44%
tabcmd/commands
   commands.py101010 0%
   constants.py771818 77%
   server.py1351818 87%
tabcmd/commands/auth
   session.py3945050 87%
tabcmd/commands/datasources_and_workbooks
   datasources_and_workbooks_command.py1571818 89%
   datasources_workbooks_views_url_parser.py14255 96%
   delete_command.py601616 73%
   export_command.py1202525 79%
   get_url_command.py1274747 63%
   publish_command.py1232828 77%
   runschedule_command.py2177 67%
tabcmd/commands/extracts
   create_extracts_command.py4288 81%
   decrypt_extracts_command.py2722 93%
   delete_extracts_command.py3766 84%
   encrypt_extracts_command.py2722 93%
   extracts.py2022 90%
   reencrypt_extracts_command.py2722 93%
   refresh_extracts_command.py481010 79%
tabcmd/commands/group
   create_group_command.py2955 83%
   delete_group_command.py2722 93%
tabcmd/commands/project
   create_project_command.py4688 83%
   delete_project_command.py3544 89%
   publish_samples_command.py3044 87%
tabcmd/commands/site
   create_site_command.py3455 85%
   delete_site_command.py2722 93%
   edit_site_command.py3822 95%
   list_command.py771212 84%
   list_sites_command.py2922 93%
tabcmd/commands/user
   add_users_command.py2955 83%
   create_site_users.py581111 81%
   create_users_command.py5999 85%
   delete_site_users_command.py4355 88%
   user_data.py2223131 86%
tabcmd/execution
   _version.py222 0%
   global_options.py12588 94%
   localize.py661111 83%
   logger_config.py6066 90%
   tabcmd_controller.py4277 83%
TOTAL287345884% 

@bcantoni

Copy link
Copy Markdown
Contributor

@copilot resolve the merge conflicts in this pull request

Copilot AI commented Jul 20, 2026

Copy link
Copy Markdown

@copilot resolve the merge conflicts in this pull request

Resolved the merge conflict in tabcmd/locales/en/tabcmd_messages_en.properties. The conflict was caused by the development branch reorganizing locale files (removing deprecated keys like no_redirect_found and no_sslcafile_found) while this PR added the new password_file_not_found and token_file_not_found keys. The resolution keeps the new error keys while accepting upstream removals. All 50 session tests continue to pass.

Copilot AI requested a review from bcantoni July 20, 2026 17:07
@bcantoni
bcantoni merged commit 742e507 into development Jul 20, 2026
22 checks passed
@bcantoni
bcantoni deleted the jac/fix-289-missing-credentials-error branch July 20, 2026 17:14
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