Skip to content

Conversation

@Guust-Franssens
Copy link
Contributor

@Guust-Franssens Guust-Franssens commented Dec 11, 2025

📥 Pull Request

✨ Description of new changes

Implements automatic update notifications that inform users when a new version of the Fabric CLI is available on PyPI. The check runs on login (fab auth login) and displays a friendly notification if an update is available.

Changes Made

New Files:

  • src/fabric_cli/utils/fab_version_check.py - Core version checking module with PyPI integration
  • tests/test_utils/test_fab_version_check.py - 100% coverage on fab_version_check.py

Modified Files:

  • src/fabric_cli/core/fab_constant.py - Added constants for update checking configuration
  • src/fabric_cli/commands/auth/fab_auth.py - Integrated version check on successful login
  • docs/essentials/settings.md - Documented the new check_updates setting

Implementation Details

  • Once per session: version check is ran whenever a user logs in using fab auth login
  • User Control: Can be disabled via fab config set check_updates false
  • Silent Failures: Doesn't interrupt user experience if PyPI is unreachable
  • Conservative Version Comparison: Uses tuple-based semantic versioning without external dependencies
  • Debug Logging: Integrated with existing fab_logger for troubleshooting

Configuration

New config key check_cli_version_updates (default: true) stored in ~/.config/fab/config.json. This setting enables/disables update notifications.

User Experience

When a user logs in and a new version is available:

$ fab auth login -u "$CLIENT_ID" -p "$CLIENT_SECRET" --tenant "$TENANT_ID"

[notice] A new release of fab is available: 1.1.0 → 1.2.0
[notice] To update, run: pip install --upgrade ms-fabric-cli

@Guust-Franssens
Copy link
Contributor Author

Guust-Franssens commented Dec 23, 2025

Thanks for the review @aviatco. Your points are valid and I will keep them in mind in my potential future PRs.

I left some of the remarks open (like proper naming and the class one) as these warrant a second review by you to verify if my changes are meeting your request.

@Guust-Franssens Guust-Franssens force-pushed the feat/inform-about-user-about-cli-updates branch from ccf89bf to f506576 Compare December 24, 2025 07:46
@Guust-Franssens Guust-Franssens force-pushed the feat/inform-about-user-about-cli-updates branch from f4b4c4e to 13acee7 Compare December 24, 2025 10:00
@Guust-Franssens
Copy link
Contributor Author

Guust-Franssens commented Dec 24, 2025

@aviatco @ayeshurun in f4b4c4e I made a change to ignore pypi.org in the VCR playback. This was causing issues in the tests/test_commands/test_auth.py.

This passes the tests however now during testing of the fab auth login, actual requests to PyPI are being made. I think it would be cleaner to either:

  • Re-record the requests made to include PyPI (preferable by one of you as I don't have the full setup)
  • I mock the function making the call to PyPI for all tests to auth login. Here I would just make it the mock return value equal to the current __version__

Could you provide some guidance here?

)
fab_ui.print_grey(msg)
elif latest_version:
fab_logger.log_debug(f"Already on latest version: {__version__}")
Copy link
Collaborator

Choose a reason for hiding this comment

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

why did you used fab_logger.log_debug and not fab_ui.print_grey? using fab_logger.log_debug means user will see it only if fab_constant.FAB_DEBUG_ENABLED is set by the user to true.

Also, are those scenarios tested?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm using fab_logger.log_debug here intentionally for the "already up to date" scenario. The rationale is:

  • Silent success when the user is already on the latest version.
  • User-facing notification only when actionable (in case of a newer version available)

100% coverage on fab_version_check.py:

Name                                        Stmts   Miss Branch BrPart  Cover   Missing
---------------------------------------------------------------------------------------
src/fabric_cli/utils/fab_version_check.py      32      0      6      0   100%
---------------------------------------------------------------------------------------
TOTAL                                          32      0      6      0   100% 

Copy link
Collaborator

Choose a reason for hiding this comment

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

agree for the use of fab_logger.log_debug
regarding tests - my Q was that if we verify the correct message is printed only when debug_enabled is true

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was already tested before by this function, however I made it a bit more explicit by adding mock_questionary_print.assert_not_called().

@patch("fabric_cli.utils.fab_version_check._fetch_latest_version_from_pypi")
def test_cli_version_check_disabled_by_config_success(
mock_fetch, mock_fab_set_state_config, mock_questionary_print
):
"""Should not display notification when update checks are disabled by config."""
newer_version = _increment_version("major")
mock_fab_set_state_config(fab_constant.FAB_CHECK_UPDATES, "false")
mock_fetch.return_value = newer_version
fab_version_check.check_and_notify_update()
mock_questionary_print.assert_not_called()

Copy link
Collaborator

Choose a reason for hiding this comment

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

What’s missing is a check that the correct message is logged when debug_enabled=True in test_cli_version_check_same_version_success. You verified mock_questionary_print.assert_not_called(), but you should also assert that log.debug was called with the expected message.

use mock_fab_set_state_config(constant.FAB_DEBUG_ENABLED, True) to set debug_enabled=True then mock fab_logget.debug and verify the message

Same for: "test_cli_version_check_fetch_failure" and "test_cli_version_check_older_version_success"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Apologies, I didn't know that you were referring to testing the logger outputs. I fixed it in b384c46

@Guust-Franssens Guust-Franssens force-pushed the feat/inform-about-user-about-cli-updates branch from 14742d2 to e3a65b1 Compare December 30, 2025 07:41
@Guust-Franssens Guust-Franssens force-pushed the feat/inform-about-user-about-cli-updates branch from 2857200 to b56ef8e Compare December 31, 2025 10:35
@Guust-Franssens Guust-Franssens force-pushed the feat/inform-about-user-about-cli-updates branch from a5f498d to b384c46 Compare January 2, 2026 08:15
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.

[FEATURE] Help me keep my fabric-cli updated

3 participants