Conversation
|
oclif update already in #392 |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
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_AGENTinRuntimeBaseCommand.init()based onthis.config.versionDetails. - Update Jest version from
^29.6.2to^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.
| } | ||
|
|
||
| // set User-Agent for runtime calls | ||
| // ex. aio-cli-plugin-runtime/@adobe/aio-cli/10.3.1 (darwin-arm64; node-v18.20.4; zsh) |
There was a problem hiding this comment.
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.
| // 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) |
| // 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) |
There was a problem hiding this comment.
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.
| // 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})` |
There was a problem hiding this comment.
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.
| // 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})` | |
| } |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Description
Related Issue
Motivation and Context
How Has This Been Tested?
Screenshots (if appropriate):
Types of changes
Checklist: