Skip to content

fix(frontier): allow omitted plan state - #498

Open
RushikeshBhavsar3605 wants to merge 1 commit into
raystack:mainfrom
RushikeshBhavsar3605:fix/plan-state-default
Open

fix(frontier): allow omitted plan state#498
RushikeshBhavsar3605 wants to merge 1 commit into
raystack:mainfrom
RushikeshBhavsar3605:fix/plan-state-default

Conversation

@RushikeshBhavsar3605

Copy link
Copy Markdown

Problem

PlanRequestBody.state is currently validated as either active or inactive.
Because the zero value ("") is not ignored, CreatePlan requests that omit
state are rejected before reaching Frontier's create logic.

Frontier already defaults an omitted plan state to active when creating a
plan.

Change

Update PlanRequestBody.state validation to ignore the zero value while
continuing to validate non-empty values against active and inactive.

Context

Related to raystack/frontier#1853

@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 91fa65d2-61d4-46b7-bcf2-ab24ed842615

📥 Commits

Reviewing files that changed from the base of the PR and between 0a5d420 and 174c3c0.

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

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

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 460-467: Update the validation options for the PlanRequestBody
state field by removing IGNORE_IF_ZERO_VALUE, so an empty state is rejected and
only active or inactive values are accepted consistently with
UpdatePlanRequestBody.state.
🪄 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: 91fa65d2-61d4-46b7-bcf2-ab24ed842615

📥 Commits

Reviewing files that changed from the base of the PR and between 0a5d420 and 174c3c0.

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

Comment on lines +460 to +467
string state = 8 [(buf.validate.field) = {
ignore: IGNORE_IF_ZERO_VALUE
string: {
in: [
"active",
"inactive"
]
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -e
printf '%s\n' '--- target file ---'
sed -n '440,510p' raystack/frontier/v1beta1/admin.proto
printf '%s\n' '--- state references ---'
rg -n --glob '!vendor/**' --glob '!node_modules/**' 'PlanRequestBody|UpdatePlanRequestBody|CreatePlan|UpdatePlan|state.*active|state.*inactive' .
printf '%s\n' '--- validation-related references ---'
rg -n --glob '!vendor/**' --glob '!node_modules/**' 'IGNORE_IF_ZERO_VALUE|protovalidate|Plan.*state|state.*default' .

Repository: raystack/proton

Length of output: 7772


🏁 Script executed:

#!/bin/bash
set -e
printf '%s\n' '--- repository files relevant to plan/state/defaults ---'
git ls-files | rg -i '(^|/)(frontier|plan|seed|yaml|yml|json|go|ts|js|py|java|proto)(/|$)|plan|seed'
printf '%s\n' '--- all active/inactive and plan-state references ---'
rg -n -i --hidden --glob '!.git/**' --glob '!node_modules/**' --glob '!vendor/**' 'active|inactive|plan.*state|state.*plan|createplan|updateplan|seed' .
printf '%s\n' '--- current diff summary and target diff ---'
git diff --stat -- raystack/frontier/v1beta1/admin.proto
git diff -- raystack/frontier/v1beta1/admin.proto | sed -n '1,180p'
printf '%s\n' '--- available schema tools ---'
command -v protoc || true
command -v buf || true

Repository: raystack/proton

Length of output: 3937


🏁 Script executed:

#!/bin/bash
set -e
python3 - <<'PY'
from pathlib import Path
import re

text = Path("raystack/frontier/v1beta1/admin.proto").read_text()
m = re.search(
    r'message PlanRequestBody \{(?P<body>.*?)\n\}\n\nmessage CreatePlanRequest',
    text,
    re.S,
)
assert m, "PlanRequestBody not found"
body = m.group("body")
field = re.search(
    r'string state = 8 \[\(buf\.validate\.field\) = \{\s*'
    r'ignore:\s*(\w+)\s*'
    r'string:\s*\{\s*in:\s*\[\s*"([^"]+)",\s*"([^"]+)"',
    body,
    re.S,
)
assert field, "PlanRequestBody.state rule not found"
ignore, first, second = field.groups()

um = re.search(
    r'message UpdatePlanRequestBody \{(?P<body>.*?)\n\}\n\nmessage UpdatePlanRequest',
    text,
    re.S,
)
assert um, "UpdatePlanRequestBody not found"
update_body = um.group("body")
update_field = re.search(
    r'string state = 5 \[\(buf\.validate\.field\)\.string = \{\s*'
    r'in:\s*\[\s*"([^"]+)",\s*"([^"]+)"',
    update_body,
    re.S,
)
assert update_field, "UpdatePlanRequestBody.state rule not found"
update_first, update_second = update_field.groups()

def validate(value, ignore_zero):
    if value == "" and ignore_zero:
        return True
    return value in (first, second)

print({
    "PlanRequestBody.state": {
        "ignore": ignore,
        "accepted_values": [first, second],
        "empty_string": validate("", ignore == "IGNORE_IF_ZERO_VALUE"),
        "active": validate("active", ignore == "IGNORE_IF_ZERO_VALUE"),
        "inactive": validate("inactive", ignore == "IGNORE_IF_ZERO_VALUE"),
        "unknown": validate("paused", ignore == "IGNORE_IF_ZERO_VALUE"),
    },
    "UpdatePlanRequestBody.state": {
        "accepted_values": [update_first, update_second],
        "empty_string": "" in (update_first, update_second),
        "active": "active" in (update_first, update_second),
        "inactive": "inactive" in (update_first, update_second),
        "unknown": "paused" in (update_first, update_second),
    },
})
PY

Repository: raystack/proton

Length of output: 483


Require an explicit plan state.

IGNORE_IF_ZERO_VALUE allows an empty PlanRequestBody.state, while UpdatePlanRequestBody.state requires active or inactive. Remove IGNORE_IF_ZERO_VALUE so both request bodies enforce the same contract.

🤖 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 460 - 467, Update the
validation options for the PlanRequestBody state field by removing
IGNORE_IF_ZERO_VALUE, so an empty state is rejected and only active or inactive
values are accepted consistently with UpdatePlanRequestBody.state.

Source: Learnings

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.

1 participant