fix(frontier): allow omitted plan state - #498
Conversation
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
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. Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (1)
raystack/frontier/v1beta1/admin.proto
| string state = 8 [(buf.validate.field) = { | ||
| ignore: IGNORE_IF_ZERO_VALUE | ||
| string: { | ||
| in: [ | ||
| "active", | ||
| "inactive" | ||
| ] | ||
| } |
There was a problem hiding this comment.
🗄️ 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 || trueRepository: 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),
},
})
PYRepository: 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
Problem
PlanRequestBody.stateis currently validated as eitheractiveorinactive.Because the zero value (
"") is not ignored,CreatePlanrequests that omitstateare rejected before reaching Frontier's create logic.Frontier already defaults an omitted plan state to
activewhen creating aplan.
Change
Update
PlanRequestBody.statevalidation to ignore the zero value whilecontinuing to validate non-empty values against
activeandinactive.Context
Related to raystack/frontier#1853