Skip to content

fix(cli): correct subscription create payload field names#2724

Merged
renuka-fernando merged 2 commits into
wso2:mainfrom
renuka-fernando:cli-fix-subscription-plan-name
Jul 16, 2026
Merged

fix(cli): correct subscription create payload field names#2724
renuka-fernando merged 2 commits into
wso2:mainfrom
renuka-fernando:cli-fix-subscription-plan-name

Conversation

@renuka-fernando

@renuka-fernando renuka-fernando commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Purpose

The `ap devportal subscription create` command was sending incorrect JSON field names in the request body. The DevPortal API (`devportal-openapi-spec-v0.9.yaml`, `SubscriptionCreateRequest`) requires `artifactId` and `subscriptionPlanId`, but the CLI was sending `apiId` and `subscriptionPlanName`. This caused the unit tests to fail and would have silently sent invalid payloads to the DevPortal at runtime.

Goals

Correct both field names in the subscription create payload so the CLI sends requests that the DevPortal API and its underlying service (`subscriptionService.js`) can parse correctly.

Approach

  • Fix `buildCreatePayload()` in `cli/src/cmd/devportal/subscription/create.go`: rename `apiId` → `artifactId` and `subscriptionPlanName` → `subscriptionPlanId`.
  • Update test assertions in `commands_test.go` to expect the corrected field names.

User stories

As a CLI user, running `ap devportal subscription create --api-id --subscription-plan ` should create a subscription with a valid request body that the DevPortal accepts.

Documentation

N/A — no user-visible behaviour change beyond the bug fix.

Automation tests

  • Unit tests: `TestRunCreateCommand_SendsJSONPayload` and `TestRunCreateCommand_OmitsSubscriptionPlanWhenEmpty` updated and passing. Full CLI test suite passes (`cd cli/src && make test`).
  • Integration tests: N/A for this change.

Security checks

  • Followed secure coding standards: yes
  • Ran FindSecurityBugs plugin: N/A (Go CLI, not Java)
  • Confirmed that this PR doesn't commit any keys, passwords, tokens, usernames, or other secrets: yes

Samples

N/A

Related PRs

N/A

Test environment

  • Go 1.23+, macOS (darwin)

…ayload

The create subscription command was sending `subscriptionPlanId` in the
JSON request body, but the DevPortal API expects `subscriptionPlanName`.
This caused the unit test to fail and would have sent the wrong field
to the server at runtime.
@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@renuka-fernando, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 24 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 38225164-d502-4717-8fe0-29f85a4fe3ef

📥 Commits

Reviewing files that changed from the base of the PR and between 72c4ff5 and 990ad63.

📒 Files selected for processing (2)
  • cli/src/cmd/devportal/subscription/commands_test.go
  • cli/src/cmd/devportal/subscription/create.go
📝 Walkthrough

Walkthrough

The subscription creation command now uses subscriptionPlanName instead of subscriptionPlanId in the request payload when --subscription-plan is provided.

Changes

Subscription creation payload

Layer / File(s) Summary
Update subscription plan payload key
cli/src/cmd/devportal/subscription/create.go
The request payload now uses subscriptionPlanName for the provided subscription plan.

Estimated code review effort: 1 (Trivial) | ~2 minutes

Suggested reviewers: shakyapr, anugayan, arshardh

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the main fix: correcting payload field names for subscription creation.
Description check ✅ Passed The description follows the required template and covers purpose, goals, approach, tests, security, and environment.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@cli/src/cmd/devportal/subscription/create.go`:
- Line 114: Update the payload construction in the subscription creation flow to
use the key subscriptionPlanId instead of subscriptionPlan, preserving the
existing selected subscriptionPlan value so downstream consumers receive the
expected plan identifier.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 5f44a7b9-b34a-463e-a4ce-2c087cc6777f

📥 Commits

Reviewing files that changed from the base of the PR and between 748d6d7 and 72c4ff5.

📒 Files selected for processing (1)
  • cli/src/cmd/devportal/subscription/create.go

Comment thread cli/src/cmd/devportal/subscription/create.go Outdated
The CLI was sending `apiId` and `subscriptionPlanName` in the subscription
create request body. The DevPortal API (devportal-openapi-spec-v0.9.yaml,
SubscriptionCreateRequest) requires `artifactId` and `subscriptionPlanId`,
which the subscriptionService.js also confirms at the destructuring site.

Update both the payload builder and the test assertions accordingly.
@renuka-fernando renuka-fernando changed the title fix(cli): use subscriptionPlanName in devportal subscription create payload fix(cli): correct subscription create payload field names Jul 16, 2026
@renuka-fernando
renuka-fernando merged commit 90ba4ba into wso2:main Jul 16, 2026
6 checks passed
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