Skip to content

feat: add useragent#341

Open
purplecabbage wants to merge 4 commits intomasterfrom
UserAgent
Open

feat: add useragent#341
purplecabbage wants to merge 4 commits intomasterfrom
UserAgent

Conversation

@purplecabbage
Copy link
Copy Markdown
Member

@purplecabbage purplecabbage commented Nov 16, 2024

Description

Related Issue

Motivation and Context

How Has This Been Tested?

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have signed the Adobe Open Source CLA.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@shazron
Copy link
Copy Markdown
Member

shazron commented Apr 7, 2026

oclif update already in #392

@shazron shazron changed the title add useragent, update oclif, jest feat: add useragent Apr 13, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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

This PR introduces a richer OpenWhisk/User-Agent value for Runtime API calls by setting process.env.__OW_USER_AGENT during command initialization, and also bumps the Jest dev dependency.

Changes:

  • Set process.env.__OW_USER_AGENT in RuntimeBaseCommand.init() based on this.config.versionDetails.
  • Update Jest version from ^29.6.2 to ^29.7.0.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
src/RuntimeBaseCommand.js Adds logic in init() to set a runtime User-Agent env var for OpenWhisk calls.
package.json Bumps Jest devDependency version.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/RuntimeBaseCommand.js Outdated
Comment thread src/RuntimeBaseCommand.js
}

// set User-Agent for runtime calls
// ex. aio-cli-plugin-runtime/@adobe/aio-cli/10.3.1 (darwin-arm64; node-v18.20.4; zsh)
Copy link

Copilot AI Apr 16, 2026

Choose a reason for hiding this comment

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

The example UA in the comment doesn’t match what the code generates (example includes @adobe/aio-cli/... and a node-v... format, while the actual string is aio-cli-plugin-runtime/${vs?.cliVersion} (...)). Update the comment to reflect the real output so it stays useful as documentation.

Suggested change
// ex. aio-cli-plugin-runtime/@adobe/aio-cli/10.3.1 (darwin-arm64; node-v18.20.4; zsh)
// ex. aio-cli-plugin-runtime/10.3.1 (darwin-arm64; 18.20.4; zsh)

Copilot uses AI. Check for mistakes.
Comment thread src/RuntimeBaseCommand.js
Comment on lines +89 to +96
// set User-Agent for runtime calls
// ex. aio-cli-plugin-runtime/@adobe/aio-cli/10.3.1 (darwin-arm64; node-v18.20.4; zsh)
const vs = this.config.versionDetails
// console.log('init ', this.config.versionDetails)
process.env.__OW_USER_AGENT =
`aio-cli-plugin-runtime/${vs?.cliVersion} (${vs?.architecture}; ${vs?.nodeVersion}; ${vs?.shell})`

debug('init ', process.env.__OW_USER_AGENT)
Copy link

Copilot AI Apr 16, 2026

Choose a reason for hiding this comment

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

New user-agent construction in init() isn’t asserted in unit tests (e.g., does not override a pre-set __OW_USER_AGENT, honors --useragent, and produces a string without "undefined" parts). Adding focused tests here would prevent regressions and clarify the intended precedence rules.

Copilot uses AI. Check for mistakes.
Comment thread src/RuntimeBaseCommand.js Outdated
Comment on lines +89 to +94
// set User-Agent for runtime calls
// ex. aio-cli-plugin-runtime/@adobe/aio-cli/10.3.1 (darwin-arm64; node-v18.20.4; zsh)
const vs = this.config.versionDetails
// console.log('init ', this.config.versionDetails)
process.env.__OW_USER_AGENT =
`aio-cli-plugin-runtime/${vs?.cliVersion} (${vs?.architecture}; ${vs?.nodeVersion}; ${vs?.shell})`
Copy link

Copilot AI Apr 16, 2026

Choose a reason for hiding this comment

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

init() now sets process.env.__OW_USER_AGENT unconditionally, which overrides the existing precedence logic in getOptions() (env var > --useragent flag/default). This breaks custom user-agent overrides. Consider only setting this value when it is not already set, or incorporate the existing flags.useragent/env value into the computed string.

Suggested change
// set User-Agent for runtime calls
// ex. aio-cli-plugin-runtime/@adobe/aio-cli/10.3.1 (darwin-arm64; node-v18.20.4; zsh)
const vs = this.config.versionDetails
// console.log('init ', this.config.versionDetails)
process.env.__OW_USER_AGENT =
`aio-cli-plugin-runtime/${vs?.cliVersion} (${vs?.architecture}; ${vs?.nodeVersion}; ${vs?.shell})`
// set User-Agent for runtime calls, but preserve any existing override
// ex. aio-cli-plugin-runtime/@adobe/aio-cli/10.3.1 (darwin-arm64; node-v18.20.4; zsh)
const vs = this.config.versionDetails
// console.log('init ', this.config.versionDetails)
if (!process.env.__OW_USER_AGENT) {
process.env.__OW_USER_AGENT =
`aio-cli-plugin-runtime/${vs?.cliVersion} (${vs?.architecture}; ${vs?.nodeVersion}; ${vs?.shell})`
}

Copilot uses AI. Check for mistakes.
Co-authored-by: Copilot <175728472+Copilot@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.

3 participants