Skip to content

fix(sign): Defaulted amoBaseUrl when signing from the Node API - #3833

Merged
Rob--W merged 1 commit into
mozilla:masterfrom
MaxFreedomPollard:fix/amo-base-url
Oct 8, 2026
Merged

Rob--W merged 1 commit into
mozilla:masterfrom
MaxFreedomPollard:fix/amo-base-url

Conversation

@MaxFreedomPollard

Copy link
Copy Markdown
Contributor

Fixes #3164.

Calling webExt.cmd.sign({apiKey, apiSecret, artifactsDir, channel, sourceDir}) from Node fails with Invalid AMO API base URL: undefined. The default only exists as a yargs default in the CLI option table (src/program.js:527), so it is applied on the command line and nowhere else. src/cmd/sign.js:23 destructures amoBaseUrl with no default, and signAddon rejects a missing value at src/util/submit-addon.js:500-503. The reporter hit this moving from 7.x to 8.x and worked around it by hardcoding amoBaseUrl: 'https://addons.mozilla.org/api/v5/', which pins them to an API version web-ext is meant to manage for them.

This moves the constant into a new dependency-free module, src/util/constants.js. src/program.js imports it and re-exports it, so import { AMO_BASE_URL } from './program.js' keeps working for existing callers and tests, and the CLI option table is untouched. src/cmd/sign.js imports it from the new module rather than from src/program.js, so a Node API caller does not pull yargs and the rest of the CLI in behind it. No command module imports src/program.js today, and src/cmd/index.js loads commands lazily for the same start-up reason (#1302).

One scope note: signAddon() in src/util/submit-addon.js still takes amoBaseUrl explicitly. It is public API, since package.json exports ./util/submit-addon, so this is a real choice rather than an oversight. I kept the change to the entry point the issue reports, but signAddon() can get the same default here if you would rather have it in one place.

The new test is "defaults the AMO base URL when it is not passed in" in tests/unit/test-cmd/test.sign.js. getStubs() always supplies amoBaseUrl, so the test copies the stub config, deletes that key, and asserts that submitAddon was called with the default. Reverting the one line in src/cmd/sign.js makes it fail with amoBaseUrl: undefined. The README example for webExt.cmd.sign() also drops the hardcoded amoBaseUrl; the signAddon() example below it keeps it, because that entry point still needs it.

Unit tests, eslint and prettier pass locally.

@Rob--W Rob--W left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good; we should wait with merging this until right before we publish a new version, because otherwise people trying out the code from README.md will find it not working.

The documented default for amoBaseUrl only existed as a yargs default in
the CLI option table, so it was applied on the command line and nowhere
else. Calling webExt.cmd.sign() from Node without that option passed
undefined down to signAddon(), which rejected it with "Invalid AMO API
base URL: undefined". The constant now lives in src/util/constants.js,
program.js imports and re-exports it so existing imports keep working,
and src/cmd/sign.js uses it as the parameter default. The README example
for webExt.cmd.sign() no longer passes amoBaseUrl, because it is no
longer needed there.

Fixes mozilla#3164
@Rob--W
Rob--W merged commit 3b0c95e into mozilla:master Oct 8, 2026
7 of 8 checks passed
@willdurand willdurand mentioned this pull request Oct 15, 2026
willdurand added a commit that referenced this pull request Oct 15, 2026
## main changes

- Added: in **web-ext lint**, add support for the Firefox 158 schema data. See: https://github.com/mozilla/addons-linter/releases/tag/10.14.0
- Fixed: silent reload failures on Chrome 125 and earlier (#3836)
- Fixed: files not being ignored when `sourceDir` contains glob characters (#3835)
- Fixed: in **web-ext sign**, fixed default `amoBaseUrl` value when signing from the Node API (#3833)

## dependencies

- Updated: dependency `pino` to 10.4.0 (#3896)
- Updated: dependency `yargs` to 17.7.3 (#3885)
- Updated: dependency `open` to 11.0.4 (#3858)

## dev dependencies

- Updated: dependency `@eslint/js` to 9.39.5 (#3886)
- Updated: dependency `brace-expansion` to 1.1.21 (#3880)
- Updated: dependency `chai` to 6.3.0 (#3892)
- Updated: dependency `fast-uri` to 3.1.8 (#3881)
- Updated: dependency `fs-extra` to 11.4.1 (#3876)
- Updated: dependency `globals` to 17.13.0 (#3890)
- Updated: dependency `mocha` to 12.0.3 (#3891)
- Updated: dependency `mozilla/addons/.github/actions/release` to 1.3 (#3878)
- Updated: dependency `prettier` to 3.9.9 (#3877)
- Updated: dependency `serialize-javascript` to 7.1.2 (#3882)
- Updated: dependency `source-map-js` to 1.2.2 (#3894)
- Updated: dependency `testdouble` to 3.23.0 (#3901)
- Updated: dependency `undici` to 7.30.0 (#3874)
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.

"AMO API base URL" must be specified even though docs say it has a default

2 participants