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
14 changes: 14 additions & 0 deletions raystack/frontier/v1beta1/models.proto
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,14 @@ message AuditLog {
}];
}

// InputHintOption represents a selectable option with a machine-readable name and user-friendly title
message InputHintOption {
// Machine-readable identifier (e.g., "sq_km", "megagram")
string name = 1;
// User-friendly display title (e.g., "Square Kilometers", "Megagram (Mg)")
string title = 2;
}
Comment on lines +521 to +527
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Add validation for InputHintOption fields to avoid empty/invalid identifiers.

Empty name values undermine the “machine‑readable identifier” contract and can collide in storage/validation. Consider enforcing non‑empty (and optionally a stable pattern) for name and title.

🛡️ Suggested validation rules
 message InputHintOption {
   // Machine-readable identifier (e.g., "sq_km", "megagram")
-  string name = 1;
+  string name = 1 [(validate.rules).string = {min_len: 1, pattern: "^[A-Za-z0-9-_]+$"}];
   // User-friendly display title (e.g., "Square Kilometers", "Megagram (Mg)")
-  string title = 2;
+  string title = 2 [(validate.rules).string = {min_len: 1}];
 }
🤖 Prompt for AI Agents
In `@raystack/frontier/v1beta1/models.proto` around lines 521 - 527,
InputHintOption allows empty/invalid identifiers; add validation rules to ensure
name is non-empty (and matches a stable machine-readable pattern) and title is
non-empty. Update the InputHintOption message to include validation annotations
(e.g., protoc-gen-validate / validate.rules) on fields name and title: require
name to be non-empty and enforce a conservative pattern such as lowercase
alphanumerics/underscores (or your project's chosen identifier regex) and
require title to be non-empty; reference the message name InputHintOption and
the fields name and title when applying these annotations so generated
code/validators will reject empty/invalid values.


// PreferenceTrait is a trait that can be used to add preferences to a resource
// it explains what preferences are available for a resource
message PreferenceTrait {
Expand Down Expand Up @@ -547,6 +555,9 @@ message PreferenceTrait {
reserved 20 to 26;

InputType input_type = 27;
// Structured input options with name and title for select/combobox/multiselect inputs
// Takes precedence over input_hints when both are provided
repeated InputHintOption input_options = 28;
Comment on lines 557 to +560
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Make the precedence rule unambiguous when input_options is empty.

If clients send input_options: [], the current wording implies input_hints is ignored, which could yield no options. Consider enforcing non‑empty lists or explicitly stating fallback behavior.

🧭 Option A: enforce non-empty lists
-  // Takes precedence over input_hints when both are provided
-  repeated InputHintOption input_options = 28;
+  // Takes precedence over input_hints when non-empty
+  repeated InputHintOption input_options = 28 [
+    (validate.rules).repeated = {min_items: 1}
+  ];
🧭 Option B: clarify fallback in comment (if empty lists are allowed)
-  // Takes precedence over input_hints when both are provided
+  // Takes precedence over input_hints when non-empty; otherwise input_hints applies
   repeated InputHintOption input_options = 28;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
InputType input_type = 27;
// Structured input options with name and title for select/combobox/multiselect inputs
// Takes precedence over input_hints when both are provided
repeated InputHintOption input_options = 28;
InputType input_type = 27;
// Structured input options with name and title for select/combobox/multiselect inputs
// Takes precedence over input_hints when non-empty
repeated InputHintOption input_options = 28 [
(validate.rules).repeated = {min_items: 1}
];
Suggested change
InputType input_type = 27;
// Structured input options with name and title for select/combobox/multiselect inputs
// Takes precedence over input_hints when both are provided
repeated InputHintOption input_options = 28;
InputType input_type = 27;
// Structured input options with name and title for select/combobox/multiselect inputs
// Takes precedence over input_hints when non-empty; otherwise input_hints applies
repeated InputHintOption input_options = 28;
🤖 Prompt for AI Agents
In `@raystack/frontier/v1beta1/models.proto` around lines 557 - 560, Clarify the
precedence rule for InputHintOption vs input_hints: update the comment for the
repeated field input_options to state explicitly that input_options only takes
precedence when it is present and non-empty; if clients send input_options: []
(an empty list), the service should fall back to using input_hints to populate
options. Mention that implementations may validate/require non-empty
input_options if they want to enforce Option A, and reference the fields
InputHintOption, input_options, and input_hints in the comment so the behavior
is unambiguous.

}

message Preference {
Expand All @@ -561,6 +572,9 @@ message Preference {
// scope_id is the identifier of the scope context (e.g., organization ID)
// Only applicable when scope_type is set
string scope_id = 7;
// value_title is the human-readable display title for the value
// Populated from InputHintOption.title when the trait has input_options configured
string value_title = 8;

google.protobuf.Timestamp created_at = 10 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
description: "The time when the preference was created.",
Expand Down
Loading