Skip to content
Merged
Show file tree
Hide file tree
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
8 changes: 6 additions & 2 deletions apps/web/utils/actions/rule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -587,8 +587,12 @@ export const createRulesOnboardingAction = actionClient

const isSet = (
value: string | undefined | null,
): value is "label" | "label_archive" | "label_archive_delayed" =>
value !== "none" && value !== undefined;
): value is
| "label"
| "label_archive"
| "label_archive_delayed"
| "move_folder"
| "move_folder_delayed" => value !== "none" && value !== undefined;
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot Sep 18, 2025

Choose a reason for hiding this comment

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

The type guard is unsound: value !== "none" && value !== undefined returns true for null and arbitrary strings while claiming to narrow to specific literals. Replace with an explicit membership check and include a null check; also tighten the parameter type to the expected union.

Prompt for AI agents
Address the following comment on apps/web/utils/actions/rule.ts at line 595:

<comment>The type guard is unsound: value !== &quot;none&quot; &amp;&amp; value !== undefined returns true for null and arbitrary strings while claiming to narrow to specific literals. Replace with an explicit membership check and include a null check; also tighten the parameter type to the expected union.</comment>

<file context>
@@ -587,8 +587,12 @@ export const createRulesOnboardingAction = actionClient
+        | &quot;label_archive&quot;
+        | &quot;label_archive_delayed&quot;
+        | &quot;move_folder&quot;
+        | &quot;move_folder_delayed&quot; =&gt; value !== &quot;none&quot; &amp;&amp; value !== undefined;
 
       // cold email blocker
</file context>
Fix with Cubic


Comment on lines 588 to 596
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Type guard bug: null and arbitrary strings pass as “set”.

value !== "none" && value !== undefined erroneously returns true for null and any non-"none" string, while the predicate narrows to specific literals. This can enable invalid actions to flow through.

Use exact membership + include null check; also narrow the param type:

-      const isSet = (
-        value: string | undefined | null,
-      ): value is
-        | "label"
-        | "label_archive"
-        | "label_archive_delayed"
-        | "move_folder"
-        | "move_folder_delayed" => value !== "none" && value !== undefined;
+      const isSet = (
+        value: CategoryAction | "none" | undefined | null,
+      ): value is CategoryAction => {
+        return (
+          value !== null &&
+          value !== undefined &&
+          (value === "label" ||
+            value === "label_archive" ||
+            value === "label_archive_delayed" ||
+            value === "move_folder" ||
+            value === "move_folder_delayed")
+        );
+      };
📝 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
const isSet = (
value: string | undefined | null,
): value is "label" | "label_archive" | "label_archive_delayed" =>
value !== "none" && value !== undefined;
): value is
| "label"
| "label_archive"
| "label_archive_delayed"
| "move_folder"
| "move_folder_delayed" => value !== "none" && value !== undefined;
const isSet = (
value: CategoryAction | "none" | undefined | null,
): value is CategoryAction => {
return (
value !== null &&
value !== undefined &&
(value === "label" ||
value === "label_archive" ||
value === "label_archive_delayed" ||
value === "move_folder" ||
value === "move_folder_delayed")
);
};

// cold email blocker
if (coldEmail && isSet(coldEmail.action)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ ${formatCategoriesForPrompt(categories)}
- Return your response in JSON format
</important>`;

const modelOptions = getModel(emailAccount.user, "chat");
const modelOptions = getModel(emailAccount.user, "economy");

const generateObject = createGenerateObject({
userEmail: emailAccount.email,
Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v2.9.45
v2.9.46
Loading