Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions raystack/frontier/v1beta1/admin.proto
Original file line number Diff line number Diff line change
Expand Up @@ -457,11 +457,14 @@ message PlanRequestBody {
int64 trial_days = 7 [(buf.validate.field).int64 = {gte: 0}];

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

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

}];

google.protobuf.Struct metadata = 20;
Expand Down