feat: add User-Agent header to all REST API calls#21
Merged
Conversation
- Create src/lib/user-agent.ts — single source of truth for User-Agent string - Set User-Agent header on all HTTP requests in ApimClient.request() - Add unit tests: tests/unit/lib/user-agent.test.ts + apim-client coverage Closes #16 Agent-Logs-Url: https://github.com/Azure/apiops-cli/sessions/7d507051-7b27-4f36-b053-acc897e40ecc Co-authored-by: petehauge <12090616+petehauge@users.noreply.github.com>
Second test now verifies User-Agent is set on unauthenticated blob requests (skipAuth=true) and that Authorization header is absent on those calls. Closes #16 Agent-Logs-Url: https://github.com/Azure/apiops-cli/sessions/7d507051-7b27-4f36-b053-acc897e40ecc Co-authored-by: petehauge <12090616+petehauge@users.noreply.github.com>
- Added TypeScriptDev learning: USER_AGENT constant in src/lib/user-agent.ts, header set in ApimClient.request() at line 108 - Added TestEngineer learning: User-Agent testing patterns for both auth paths - Closes #16 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: petehauge <12090616+petehauge@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
petehauge
April 29, 2026 05:16
View session
There was a problem hiding this comment.
Pull request overview
Adds a centralized USER_AGENT constant and applies it to APIM HTTP requests so server-side telemetry can distinguish apiops-cli traffic by version.
Changes:
- Introduces
src/lib/user-agent.tsas the single source of truth forapiops-cli/<version>usingpackage.jsonat runtime. - Sets
User-Agenton allApimClient.request()calls (includingskipAuthblob fetches). - Adds/extends unit tests to validate the constant format and request header behavior.
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
src/lib/user-agent.ts |
New shared USER_AGENT constant derived from package.json version. |
src/clients/apim-client.ts |
Adds User-Agent header setting in the central request path. |
tests/unit/lib/user-agent.test.ts |
New unit tests validating USER_AGENT format. |
tests/unit/clients/apim-client.test.ts |
Adds tests ensuring User-Agent is present for both auth and skipAuth requests. |
package-lock.json |
Lockfile metadata updates (unrelated to runtime behavior). |
.squad/agents/typescriptdev/history.md |
Records implementation notes for Issue #16. |
.squad/agents/testengineer/history.md |
Records added test coverage for Issue #16. |
Addresses PR review feedback: the production defaultArmRequest fetch call in keyvault-checker.ts was missing the User-Agent header. Now imports USER_AGENT from user-agent.ts and adds it alongside Authorization/Accept. Adds a unit test that calls checkKeyVaultSecretAccess without an injected armRequest (so defaultArmRequest runs) and verifies every fetch call carries the correct User-Agent header. Closes #16 Agent-Logs-Url: https://github.com/Azure/apiops-cli/sessions/8b196bc2-81c8-4320-9a60-c3655ee4b3bc Co-authored-by: petehauge <12090616+petehauge@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Azure/apiops-cli/sessions/8b196bc2-81c8-4320-9a60-c3655ee4b3bc Co-authored-by: petehauge <12090616+petehauge@users.noreply.github.com>
EMaher
requested changes
Apr 29, 2026
…tern Agent-Logs-Url: https://github.com/Azure/apiops-cli/sessions/16641d14-86ab-42af-9e18-34ecbc7c4bd1 Co-authored-by: EMaher <9244742+EMaher@users.noreply.github.com>
EMaher
approved these changes
Apr 29, 2026
EMaher
added a commit
that referenced
this pull request
May 19, 2026
Closes #21 Adds full implementation of `apiops compare` command for comparing two Azure API Management instances via the ARM REST API. Files added: - src/lib/compare-normalizer.ts — normalization engine (string replacement, auto-ID keying, resource map building) - src/lib/compare-differ.ts — diff engine (deep JSON diff, resource map comparison, secret/credential skip) - src/services/compare-service.ts — orchestrator (hierarchical comparison: top-level, API children, product/gateway/workspace children) - src/cli/compare-command.ts — CLI registration + text/JSON output - tests/unit/lib/compare-normalizer.test.ts - tests/unit/lib/compare-differ.test.ts - tests/unit/services/compare-service.test.ts - tests/unit/cli/compare-command.test.ts Files modified: - src/models/config.ts — adds CompareConfig - src/cli/index.ts — registers compare command - specs/contracts/cli-commands.md — documents compare command - specs/tasks.md — Phase 9 with all compare tasks marked done Agent-Logs-Url: https://github.com/Azure/apiops-cli/sessions/a77d8d45-6ce6-4ca7-a7ea-9191c35edc17 Co-authored-by: EMaher <9244742+EMaher@users.noreply.github.com>
EMaher
added a commit
that referenced
this pull request
May 19, 2026
Closes #21 Adds full implementation of `apiops compare` command for comparing two Azure API Management instances via the ARM REST API. Files added: - src/lib/compare-normalizer.ts — normalization engine (string replacement, auto-ID keying, resource map building) - src/lib/compare-differ.ts — diff engine (deep JSON diff, resource map comparison, secret/credential skip) - src/services/compare-service.ts — orchestrator (hierarchical comparison: top-level, API children, product/gateway/workspace children) - src/cli/compare-command.ts — CLI registration + text/JSON output - tests/unit/lib/compare-normalizer.test.ts - tests/unit/lib/compare-differ.test.ts - tests/unit/services/compare-service.test.ts - tests/unit/cli/compare-command.test.ts Files modified: - src/models/config.ts — adds CompareConfig - src/cli/index.ts — registers compare command - specs/contracts/cli-commands.md — documents compare command - specs/tasks.md — Phase 9 with all compare tasks marked done Agent-Logs-Url: https://github.com/Azure/apiops-cli/sessions/a77d8d45-6ce6-4ca7-a7ea-9191c35edc17 Co-authored-by: EMaher <9244742+EMaher@users.noreply.github.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.
defaultArmRequestin keyvault-checker.ts missing User-Agent)USER_AGENTimport + header todefaultArmRequestinsrc/services/keyvault-checker.tsdefaultArmRequestcalls