Skip to content

feat(frontier)!: move CreatePlan and UpdatePlan to AdminService and add ListAllPlans - #496

Merged
rohilsurana merged 4 commits into
mainfrom
feat/admin-plan-apis
Aug 4, 2026
Merged

feat(frontier)!: move CreatePlan and UpdatePlan to AdminService and add ListAllPlans#496
rohilsurana merged 4 commits into
mainfrom
feat/admin-plan-apis

Conversation

@rohilsurana

@rohilsurana rohilsurana commented Jul 31, 2026

Copy link
Copy Markdown
Member

What

Move the plan write APIs to AdminService and add a new ListAllPlans API.

  • CreatePlan and UpdatePlan move from FrontierService to AdminService.
  • New ListAllPlans on AdminService. It returns every plan, including inactive ones. An empty state returns all plans; a set state filters to it.
  • The plan write messages (PlanRequestBody, CreatePlanRequest, CreatePlanResponse, UpdatePlanRequest, UpdatePlanResponse) move from frontier.proto into admin.proto, so admin.proto does not import frontier.proto.
  • UpdatePlan takes a new UpdatePlanRequestBody (title, description, on_start_credits, trial_days, state, metadata). It has no name, interval, or products because UpdatePlan does not change those. It is a full write: an omitted field is cleared, not left unchanged. UpdatePlanRequest.body is required.
  • ListPlans and GetPlan, and their messages, stay on FrontierService in frontier.proto. ListPlans still returns active plans only.
  • Validation: plan state must be active or inactive on the write bodies (empty is rejected, so state is required); the ListAllPlans filter allows an empty state to mean "all"; on_start_credits and trial_days must be zero or more.

Why

Plan writes are admin only. Today they sit on FrontierService and are gated to platform superusers by the server. Moving them to AdminService puts them on the admin surface where they belong.

The billing reconcile flow in Frontier needs to read every plan for export, including inactive ones. ListPlans returns active plans only, so it cannot see an inactive plan. ListAllPlans fills that gap.

The state values (active / inactive) follow frontier's billing convention: prices use PriceStateInactive = "inactive" (billing/product/product.go), and no billing code uses disabled.

Breaking change and migration

CreatePlan and UpdatePlan are removed from FrontierService.

  • gRPC and Connect callers must switch the method path from FrontierService to AdminService. The old paths return UNIMPLEMENTED.
  • Message full names are unchanged (same package), so message wire and JSON stay compatible. But UpdatePlanRequest.body changed from PlanRequestBody to the new UpdatePlanRequestBody on a new field number (field 2 is reserved, body is now field 3). This is wire-safe, but the Go type of UpdatePlanRequest.Body changes, which is a compile break for Go callers of UpdatePlan.
  • Per-file codegen (TypeScript protobuf-es, Python) will see the moved messages relocate from the frontier module to the admin module, so those imports must change.
  • A caller that only re-points its URL to AdminService but keeps its old JSON body will not get an error for the fields that no longer exist on the update body: the JSON codec discards unknown fields, so name, interval, and products are silently dropped from an UpdatePlan body.
  • A CreatePlan or UpdatePlan caller that used to omit state (the server defaulted it to active) now gets INVALID_ARGUMENT, because state is validated to active/inactive.
  • buf breaking passes at the WIRE level; the service surface change above is intentional and not covered by that gate.

Testing

  • buf build, buf lint, and buf breaking against main all pass.

@github-actions

github-actions Bot commented Jul 31, 2026

Copy link
Copy Markdown

The latest Buf updates on your PR. Results from workflow Validate / validate (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed⏩ skipped✅ passed✅ passedAug 3, 2026, 9:52 AM

@rohilsurana
rohilsurana marked this pull request as ready for review July 31, 2026 09:52
@rohilsurana
rohilsurana force-pushed the feat/admin-plan-apis branch from 51559d3 to ae6d5a6 Compare July 31, 2026 09:53
@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The protobuf contract moves plan creation and update operations from FrontierService to AdminService. AdminService also provides ListAllPlans with optional active or inactive state filtering. New messages define plan fields and validation rules. Create requests require a body. Update requests require a nonempty plan ID and a full-write body. FrontierService retains plan listing and retrieval.

Suggested reviewers: amangit07

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description check ✅ Passed The description clearly explains the service changes, new API, validation rules, breaking changes, and testing.
Title check ✅ Passed The title clearly summarizes moving plan write APIs to AdminService and adding ListAllPlans.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

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.

@rohilsurana
rohilsurana marked this pull request as draft July 31, 2026 09:54

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
raystack/frontier/v1beta1/admin.proto (2)

441-444: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Restrict state to known values.

The comment documents that valid values are "active" or "disabled", or empty for all plans. The field has no validation enforcing this. An unrecognized value silently returns an empty result instead of surfacing an error. Add a buf.validate.field constraint, similar to the interval field on PlanRequestBody.

♻️ Proposed validation
 message ListAllPlansRequest {
   // filter by plan state, e.g. "active" or "disabled". an empty value returns all plans
-  string state = 1;
+  string state = 1 [(buf.validate.field).string = {
+    in: [
+      "",
+      "active",
+      "disabled"
+    ]
+  }];
 }
🤖 Prompt for 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.

In `@raystack/frontier/v1beta1/admin.proto` around lines 441 - 444, Update
ListAllPlansRequest.state with a buf.validate.field string constraint limiting
values to "active", "disabled", or the empty string, following the validation
pattern used by PlanRequestBody.interval. Preserve empty state as the request
for all plans and reject unrecognized values during validation.

450-471: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Apply the same validation rigor to state, on_start_credits, and trial_days.

interval (line 457) restricts input to a known set of values, but state (line 468) accepts any string with no constraint, so it has the same silent-mismatch risk as ListAllPlansRequest.state. Additionally, on_start_credits and trial_days (lines 465-466) accept negative int64 values with no lower-bound check, even though negative credits or negative trial days are not meaningful business values.

♻️ Proposed validation
   int64 on_start_credits = 6;
-  int64 trial_days = 7;
+  int64 trial_days = 7 [(buf.validate.field).int64.gte = 0];

-  string state = 8;
+  string state = 8 [(buf.validate.field).string = {
+    in: [
+      "active",
+      "disabled"
+    ]
+  }];
🤖 Prompt for 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.

In `@raystack/frontier/v1beta1/admin.proto` around lines 450 - 471, Update
PlanRequestBody fields state, on_start_credits, and trial_days to add validation
consistent with the existing request validation: constrain state to the
supported plan-state values using the established state validation, and require
on_start_credits and trial_days to be non-negative. Keep the existing field
types and interval validation unchanged.
🤖 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.

Nitpick comments:
In `@raystack/frontier/v1beta1/admin.proto`:
- Around line 441-444: Update ListAllPlansRequest.state with a
buf.validate.field string constraint limiting values to "active", "disabled", or
the empty string, following the validation pattern used by
PlanRequestBody.interval. Preserve empty state as the request for all plans and
reject unrecognized values during validation.
- Around line 450-471: Update PlanRequestBody fields state, on_start_credits,
and trial_days to add validation consistent with the existing request
validation: constrain state to the supported plan-state values using the
established state validation, and require on_start_credits and trial_days to be
non-negative. Keep the existing field types and interval validation unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 2b2e103a-8583-4771-80ec-ad38b1912a78

📥 Commits

Reviewing files that changed from the base of the PR and between 91eaffc and ae6d5a6.

📒 Files selected for processing (2)
  • raystack/frontier/v1beta1/admin.proto
  • raystack/frontier/v1beta1/frontier.proto
💤 Files with no reviewable changes (1)
  • raystack/frontier/v1beta1/frontier.proto

@rohilsurana
rohilsurana marked this pull request as ready for review July 31, 2026 10:06
@rohilsurana

Copy link
Copy Markdown
Member Author

Applied both validation nits in fc68fa3: ListAllPlansRequest.state and PlanRequestBody.state are constrained to the known states, and on_start_credits/trial_days are now gte 0. One tweak: I kept "" in the allowed set for PlanRequestBody.state so an omitted state stays valid (the server defaults it to active on create and update, and CreatePlan callers omit it today).

@rohilsurana
rohilsurana force-pushed the feat/admin-plan-apis branch from 634beca to 44039cd Compare August 3, 2026 07:24
@rohilsurana
rohilsurana marked this pull request as ready for review August 4, 2026 10:01

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

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 `@raystack/frontier/v1beta1/admin.proto`:
- Around line 459-465: Update PlanRequestBody.state validation to include
IGNORE_IF_ZERO_VALUE so an omitted empty state passes validation and the server
can apply the active default. Keep UpdatePlanRequestBody.state using strict
active/inactive validation without this ignore option.
🪄 Autofix

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: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 56870105-6600-49a8-a5e4-b0cac1819e39

📥 Commits

Reviewing files that changed from the base of the PR and between ae6d5a6 and 01c105d.

📒 Files selected for processing (1)
  • raystack/frontier/v1beta1/admin.proto

Comment thread raystack/frontier/v1beta1/admin.proto
@rohilsurana
rohilsurana merged commit 0a5d420 into main Aug 4, 2026
3 checks passed
@rohilsurana
rohilsurana deleted the feat/admin-plan-apis branch August 4, 2026 11:02
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.

2 participants