fix: add ms-fabric-cli user agent to cicd when running deploy cmd#269
Open
aviatco wants to merge 1 commit into
Open
fix: add ms-fabric-cli user agent to cicd when running deploy cmd#269aviatco wants to merge 1 commit into
aviatco wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR centralizes Fabric CLI User-Agent construction into a dedicated utility module and ensures the deploy command always sets a CLI-controlled User-Agent (optionally prefixed with the fabric-cicd library version) to improve attribution/telemetry for CICD-triggered deployments.
Changes:
- Added
fab_user_agent.pyutility with sharedbuild_user_agent(...)andresolve_library_user_agent(...)helpers (including host-app suffix handling). - Updated API request handling and
deploy_with_config_fileto use the centralized User-Agent logic and enforce a CLI-controlled deploy User-Agent. - Added/updated tests to validate User-Agent behavior and moved host-app suffix tests into the new utility test module; added a changelog entry.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
src/fabric_cli/utils/fab_user_agent.py |
New shared utility for building CLI User-Agent strings and resolving host library versions. |
src/fabric_cli/client/fab_api_client.py |
Replaces inline User-Agent construction with the new shared utility. |
src/fabric_cli/commands/fs/deploy/fab_fs_deploy_config_file.py |
Forces CLI-controlled User-Agent for deploy runs (with optional CICD prefix). |
tests/test_utils/test_fab_user_agent.py |
New unit tests for the new User-Agent utility functions. |
tests/test_core/test_fab_api_client.py |
Removes host-app suffix tests that moved to the new utility test module. |
tests/test_commands/test_deploy.py |
Adds deploy-specific tests to assert CICD-prefixed User-Agent behavior and prevent spoofing via params. |
.changes/unreleased/fixed-20260726-120000.yaml |
Changelog entry documenting the deployment User-Agent attribution fix. |
| from fabric_cli.core.fab_exceptions import FabricCLIError | ||
| from fabric_cli.core.fab_msal_bridge import create_fabric_token_credential | ||
| from fabric_cli.utils import fab_ui | ||
| from fabric_cli.utils.fab_user_agent import build_user_agent, resolve_library_user_agent |
Comment on lines
+69
to
+72
| with patch( | ||
| "fabric_cli.utils.fab_user_agent.importlib.metadata.version", | ||
| side_effect=importlib.metadata.PackageNotFoundError, | ||
| ): |
ayeshurun
reviewed
Jul 26, 2026
| @@ -0,0 +1,6 @@ | |||
| kind: fixed | |||
| body: Set User Agent suffix for Fabric CLI deploy command. This allows the Fabric CICD service to identify the host application that is invoking the deployment, which can be useful for logging, analytics, and debugging purposes. | |||
Collaborator
There was a problem hiding this comment.
why all these changes? only need to tell cicd on it.
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
This pull request refactors how the Fabric CLI sets and manages the User-Agent string for deployment commands, making it easier to attribute deployments and improving telemetry for the Fabric CICD service. The logic for building and resolving User-Agent strings is now centralized in a new utility module, and the deployment command ensures that the correct User-Agent is always set, regardless of user input. Comprehensive tests have been added and updated to verify this behavior.
User-Agent construction and attribution:
fab_user_agent.pythat centralizes logic for building the User-Agent string (build_user_agent) and resolving library versions for attribution (resolve_library_user_agent). This ensures consistent and maintainable User-Agent formatting across the CLI.fab_fs_deploy_config_file.pyto always set a CLI-controlled User-Agent, combining both the CICD library version and the CLI's own User-Agent. This prevents users from spoofing the User-Agent via parameters and enables accurate attribution for telemetry and analytics. [1] [2]Refactoring and code cleanup:
fab_api_client.pyand replaced it with calls to the new utility functions, simplifying the client code and removing redundant code. [1] [2] [3] [4]Testing improvements:
test_fab_user_agent.pyto thoroughly test User-Agent construction, environment variable handling, and library version resolution.test_fab_api_client.pytotest_fab_user_agent.pyfor better organization. [1] [2]Documentation and changelog: