Skip to content

feat: add User-Agent header to all REST API calls#21

Merged
petehauge merged 6 commits into
mainfrom
copilot/issue-16-implementation
Apr 29, 2026
Merged

feat: add User-Agent header to all REST API calls#21
petehauge merged 6 commits into
mainfrom
copilot/issue-16-implementation

Conversation

Copy link
Copy Markdown

Copilot AI commented Apr 29, 2026

  • Read PR review feedback (reviewer: defaultArmRequest in keyvault-checker.ts missing User-Agent)
  • Add USER_AGENT import + header to defaultArmRequest in src/services/keyvault-checker.ts
  • Add unit test verifying User-Agent on defaultArmRequest calls
  • Build + lint + 753 tests pass
  • Code review clean-up: removed redundant assertions in user-agent.test.ts and keyvault-checker.test.ts
  • CodeQL: 0 alerts

Copilot AI and others added 3 commits April 29, 2026 05:10
- 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>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.ts as the single source of truth for apiops-cli/<version> using package.json at runtime.
  • Sets User-Agent on all ApimClient.request() calls (including skipAuth blob 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.

Comment thread src/clients/apim-client.ts
Copilot AI and others added 2 commits April 29, 2026 14:58
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>
Comment thread src/clients/apim-client.ts
Copilot AI requested a review from EMaher April 29, 2026 15:26
@petehauge petehauge merged commit cbc7db7 into main Apr 29, 2026
6 checks passed
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>
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.

4 participants