Skip to content

Publish does not respect --cloud flag #230

Description

@JeffRuocco-agilerank

Command that triggered the bug

apiops publish

Expected behavior

https://management.usgovcloudapi.net should be used when --cloud usgov is provided, as seen with the apiops extract command:

$ apiops extract \
  --subscription-id {subscriptionId} \
  --resource-group {resourceGroup} \
  --service-name {serviceName} \
  --output ./apiops/apim-artifacts/extract \
  --filter ./apiops/configuration.extractor.yaml \
  --cloud usgov \
  --log-level debug
2026-07-14T15:44:15.515Z [DEBUG] Loaded filter config from ./apiops/configuration.extractor.yaml
2026-07-14T15:44:15.519Z [INFO] Starting extraction from apim-artls...
2026-07-14T15:44:15.519Z [DEBUG] Output directory: ./apiops/apim-artifacts/extract
2026-07-14T15:44:15.519Z [INFO] Extracting tier 1 resources (independent)...
2026-07-14T15:44:16.363Z [DEBUG] HTTP GET https://management.usgovcloudapi.net/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.ApiManagement/service/{serviceName}/workspaces?api-version=2024-10-01-preview

Actual behavior

The --cloud usgov flag does not appear to be respected when using the publish command. https://management.azure.com is being used instead of https://management.usgovcloudapi.net:

$ apiops publish \
  --log-level debug \
  --subscription-id {subscriptionId} \
  --resource-group {resourceGroup} \
  --service-name {serviceName} \
  --source ./apiops/apim-artifacts \
  --overrides ./apiops/configuration.apim.yaml \
  --commit-id {commitId} \
  --dry-run \
  --cloud usgov
2026-07-14T15:34:13.887Z [DEBUG] Loaded override config from ./apiops/configuration.apim.yaml
2026-07-14T15:34:13.887Z [DEBUG] Using incremental publish with commit ID: {commitId}
2026-07-14T15:34:14.775Z [DEBUG] HTTP GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}?api-version=2021-04-01
2026-07-14T15:34:15.104Z [ERROR] Fatal error during publish: [{"name":"Error","message":"Resource group '{resourceGroup}' not found in subscription '{subscriptionId}'. Ensure the resource group exists before publishing.","stack":"Error: Resource group '{resourceGroup}' not found in subscription '{subscriptionId}'. Ensure the resource group exists before publishing.\n    at ApimClient.validatePreFlight (file:///C:/AgileRank/{resourceGroup}-hub-api/node_modules/@peterhauge/apiops-cli/dist/clients/apim-client.js:584:19)\n    at process.processTicksAndRejections (node:internal/process/task_queues:104:5)\n    at async runPublish (file:///C:/AgileRank/{resourceGroup}-hub-api/node_modules/@peterhauge/apiops-cli/dist/services/publish-service.js:39:9)\n    at async executePublish (file:///C:/AgileRank/{resourceGroup}-hub-api/node_modules/@peterhauge/apiops-cli/dist/cli/publish-command.js:91:20)\n    at async Command.<anonymous> (file:///C:/AgileRank/{resourceGroup}-hub-api/node_modules/@peterhauge/apiops-cli/dist/cli/publish-command.js:31:9)\n    at async Command.parseAsync (C:\\AgileRank\\{resourceGroup}-hub-api\\node_modules\\commander\\lib\\command.js:1122:5)\n    at async file:///C:/AgileRank/{resourceGroup}-hub-api/node_modules/@peterhauge/apiops-cli/dist/cli/index.js:65:5"}]

--- Summary ---
0 creates/updates, 0 deletes, 0 skipped
1 errors

apiops CLI version

0.4.0-alpha.2

Environment details

Local
Windows 11
Node v26.0.0
Bash

GitHub Actions
ubuntu-latest
Node v22
Bash

CI/CD environment

GitHub Actions

Is this bug blocking you?

Yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:bugSomething broken

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions