feat: dojo research #689

Merged
Sainan merged 6 commits from guild-tech into main 2025-01-03 00:06:50 -08:00
7 changed files with 154 additions and 17 deletions

View File

@ -3,9 +3,8 @@ import { getAccountIdForRequest } from "@/src/services/loginService";
import { getJSONfromString } from "@/src/helpers/stringHelpers";
import { Inventory } from "@/src/models/inventoryModels/inventoryModel";
import { Guild } from "@/src/models/guildModel";
import { ICreateGuildRequest } from "@/src/types/guildTypes";
const createGuildController: RequestHandler = async (req, res) => {
export const createGuildController: RequestHandler = async (req, res) => {
const accountId = await getAccountIdForRequest(req);
const payload = getJSONfromString(String(req.body)) as ICreateGuildRequest;
@ -34,4 +33,6 @@ const createGuildController: RequestHandler = async (req, res) => {
res.json(guild);
};
export { createGuildController };
interface ICreateGuildRequest {
guildName: string;
}

View File

@ -1,5 +1,100 @@
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
import { RequestHandler } from "express";
import { getGuildForRequestEx } from "@/src/services/guildService";
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
import { ExportDojoRecipes } from "warframe-public-export-plus";
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
import { getAccountIdForRequest } from "@/src/services/loginService";
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
import { addMiscItems, getInventory, updateCurrency } from "@/src/services/inventoryService";
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
import { IMiscItem } from "@/src/types/inventoryTypes/inventoryTypes";
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
import { IInventoryChanges } from "@/src/types/purchaseTypes";
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
export const guildTechController: RequestHandler = (_req, res) => {
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
res.status(500).end(); // This is what I got for a fresh clan.
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
export const guildTechController: RequestHandler = async (req, res) => {
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
const accountId = await getAccountIdForRequest(req);
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
const inventory = await getInventory(accountId);
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
const guild = await getGuildForRequestEx(req, inventory);
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
const data = JSON.parse(String(req.body)) as TGuildTechRequest;
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
if (data.Action == "Sync") {
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
res.json({
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
TechProjects: guild.toJSON().TechProjects
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
});
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
} else if (data.Action == "Start") {
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
const recipe = ExportDojoRecipes.research[data.RecipeType!];
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
guild.TechProjects ??= [];
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
if (!guild.TechProjects.find(x => x.ItemType == data.RecipeType)) {
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
guild.TechProjects.push({
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
ItemType: data.RecipeType!,
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
ReqCredits: scaleRequiredCount(recipe.price),
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
ReqItems: recipe.ingredients.map(x => ({
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
ItemType: x.ItemType,
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
ItemCount: scaleRequiredCount(x.ItemCount)
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
})),
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
State: 0
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
});
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
}
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
await guild.save();
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
res.end();
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
} else if (data.Action == "Contribute") {
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
const contributions = data as IGuildTechContributeFields;
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
const techProject = guild.TechProjects!.find(x => x.ItemType == contributions.RecipeType)!;
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
if (contributions.RegularCredits > techProject.ReqCredits) {
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
contributions.RegularCredits = techProject.ReqCredits;
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
}
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
techProject.ReqCredits -= contributions.RegularCredits;
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
const miscItemChanges = [];
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
for (const miscItem of contributions.MiscItems) {
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
const reqItem = techProject.ReqItems.find(x => x.ItemType == miscItem.ItemType);
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
if (reqItem) {
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
if (miscItem.ItemCount > reqItem.ItemCount) {
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
miscItem.ItemCount = reqItem.ItemCount;
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
}
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
reqItem.ItemCount -= miscItem.ItemCount;
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
miscItemChanges.push({
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
ItemType: miscItem.ItemType,
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
ItemCount: miscItem.ItemCount * -1
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
});
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
}
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
}
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
addMiscItems(inventory, miscItemChanges);
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
const inventoryChanges: IInventoryChanges = {
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
...updateCurrency(inventory, contributions.RegularCredits, false),
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
MiscItems: miscItemChanges
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
};
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
if (techProject.ReqCredits == 0 && !techProject.ReqItems.find(x => x.ItemCount > 0)) {
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
// This research is now fully funded.
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
techProject.State = 1;
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
const recipe = ExportDojoRecipes.research[data.RecipeType!];
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
techProject.CompletionDate = new Date(new Date().getTime() + recipe.time * 1000);
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
}
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
await guild.save();
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
await inventory.save();
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
res.json({
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
InventoryChanges: inventoryChanges
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
});
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
} else {
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
throw new Error(`unknown guildTech action: ${data.Action}`);
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
}
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
};
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
type TGuildTechRequest = {
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
Action: string;
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
} & Partial<IGuildTechStartFields> &
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
Partial<IGuildTechContributeFields>;
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
interface IGuildTechStartFields {
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
Mode: "Guild";
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
RecipeType: string;
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
}
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
interface IGuildTechContributeFields {
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
ResearchId: "";
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
RecipeType: string;
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
RegularCredits: number;
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
MiscItems: IMiscItem[];
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
VaultCredits: number;
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
VaultMiscItems: IMiscItem[];
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
}
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
const scaleRequiredCount = (count: number): number => {
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
// The recipes in the export are for Moon clans. For now we'll just assume we only have Ghost clans.
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
return Math.max(1, Math.trunc(count / 100));
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
};

coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

⚠️ Potential issue

"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from techProject.ReqCredits and reqItem.ItemCount without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp ReqCredits or ItemCount to a minimum of zero.

- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+   0,
+   techProject.ReqCredits - contributions.RegularCredits
+ );
 
 for (const miscItem of contributions.MiscItems) {
   ...
   reqItem.ItemCount = Math.max(
     0,
     reqItem.ItemCount - miscItem.ItemCount
   );
   ...
 }

Committable suggestion skipped: line range outside the PR's diff.

_:hammer_and_wrench: Refactor suggestion_ _:warning: Potential issue_ **"Contribute" action needs item and credit boundary checks.** The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero. ```diff - techProject.ReqCredits -= contributions.RegularCredits; + techProject.ReqCredits = Math.max( + 0, + techProject.ReqCredits - contributions.RegularCredits + ); for (const miscItem of contributions.MiscItems) { ... reqItem.ItemCount = Math.max( 0, reqItem.ItemCount - miscItem.ItemCount ); ... } ``` > Committable suggestion skipped: line range outside the PR's diff. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2025-01-02 17:37:00 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

🛠️ Refactor suggestion

Recipe validation and duplicate project checks are missing

Based on the code analysis, the review comment is correct. The current implementation:

  1. Directly accesses ExportDojoRecipes.research[data.RecipeType!] without validating if the recipe exists
  2. Has no checks to prevent duplicate projects with the same RecipeType
  3. Uses the recipe object without null checks, which could cause runtime errors

The suggested fix in the review comment is appropriate as it addresses both issues:

  • Validates recipe existence
  • Prevents duplicate projects
🔗 Analysis chain

Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same RecipeType isn't already present or that the RecipeType actually exists in ExportDojoRecipes.research. You might want to:

  1. Verify the recipe is valid.
  2. Ensure duplicates are either prevented or handled.
 if (!recipe) {
   return res.status(400).json({ error: "Unknown recipe type" });
 }
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+  return res.status(400).json({ error: "This project already exists" });
+}

Let me verify the concerns by checking the codebase.


Let me check the ExportDojoRecipes structure and any existing validation.


Let me try a different approach to check the validation and recipe structure.


Let me check one more thing to verify the duplicate project handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
  $$$
}'

# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes" 

Length of output: 4617


Script:

#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
  $$$
}'

# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2

Length of output: 93


Script:

#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5

# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
  $$$'

Length of output: 1234


Script:

#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2

# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2

Length of output: 390

_:bulb: Codebase verification_ _:hammer_and_wrench: Refactor suggestion_ **Recipe validation and duplicate project checks are missing** Based on the code analysis, the review comment is correct. The current implementation: 1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists 2. Has no checks to prevent duplicate projects with the same `RecipeType` 3. Uses the recipe object without null checks, which could cause runtime errors The suggested fix in the review comment is appropriate as it addresses both issues: - Validates recipe existence - Prevents duplicate projects <details> <summary>🔗 Analysis chain</summary> **Check for duplicate or invalid project requests in "Start" action.** Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to: 1. Verify the recipe is valid. 2. Ensure duplicates are either prevented or handled. ```diff if (!recipe) { return res.status(400).json({ error: "Unknown recipe type" }); } +if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) { + return res.status(400).json({ error: "This project already exists" }); +} ``` --- Let me verify the concerns by checking the codebase. --- Let me check the ExportDojoRecipes structure and any existing validation. --- Let me try a different approach to check the validation and recipe structure. --- Let me check one more thing to verify the duplicate project handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Search for recipe validation and duplicate checks in guildTechController ast-grep --pattern 'if (data.Action == "Start") { $$$ }' # Also check the ExportDojoRecipes structure rg -l "ExportDojoRecipes" ``` Length of output: 4617 --- Script: ```shell #!/bin/bash # Check ExportDojoRecipes structure and validation ast-grep --pattern 'const ExportDojoRecipes = { $$$ }' # Check if there's any validation for RecipeType rg "RecipeType.*validation" -A 2 ``` Length of output: 93 --- Script: ```shell #!/bin/bash # Look for the ExportDojoRecipes definition with a more flexible pattern rg "ExportDojoRecipes.*=" -A 5 # Check how RecipeType is used in the controller ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_]; $$$' ``` Length of output: 1234 --- Script: ```shell #!/bin/bash # Check if there's any existing duplicate check for TechProjects rg "TechProjects.*some" -A 2 # Look for any other validation related to TechProjects rg "TechProjects.*find" -A 2 ``` Length of output: 390 </details> <!-- This is an auto-generated comment by CodeRabbit -->

View File

@ -1,5 +1,12 @@
import { IGuildDatabase, IDojoComponentDatabase } from "@/src/types/guildTypes";
import {
IGuildDatabase,
IDojoComponentDatabase,
ITechProjectDatabase,
ITechProjectClient
} from "@/src/types/guildTypes";
import { model, Schema } from "mongoose";
import { typeCountSchema } from "./inventoryModels/inventoryModel";
import { toMongoDate } from "../helpers/inventoryHelpers";
const dojoComponentSchema = new Schema<IDojoComponentDatabase>({
pf: { type: String, required: true },
@ -10,12 +17,35 @@ const dojoComponentSchema = new Schema<IDojoComponentDatabase>({
CompletionTime: Date
});
const techProjectSchema = new Schema<ITechProjectDatabase>(
{
ItemType: String,
ReqCredits: Number,
ReqItems: [typeCountSchema],
State: Number,
CompletionDate: Date
},
{ _id: false }
);
techProjectSchema.set("toJSON", {
virtuals: true,
transform(_doc, obj) {
const db = obj as ITechProjectDatabase;
const client = obj as ITechProjectClient;
if (db.CompletionDate) {
client.CompletionDate = toMongoDate(db.CompletionDate);
}
}
});
const guildSchema = new Schema<IGuildDatabase>(
{
Name: { type: String, required: true },
DojoComponents: [dojoComponentSchema],
DojoCapacity: { type: Number, default: 100 },
DojoEnergy: { type: Number, default: 5 }
DojoEnergy: { type: Number, default: 5 },
TechProjects: { type: [techProjectSchema], default: undefined }
},
{ id: false }
);

View File

@ -61,7 +61,7 @@ import {
import { toMongoDate, toOid } from "@/src/helpers/inventoryHelpers";
import { EquipmentSelectionSchema } from "./loadoutModel";
const typeCountSchema = new Schema<ITypeCount>({ ItemType: String, ItemCount: Number }, { _id: false });
export const typeCountSchema = new Schema<ITypeCount>({ ItemType: String, ItemCount: Number }, { _id: false });
const focusXPSchema = new Schema<IFocusXP>(
{

View File

@ -2,17 +2,22 @@ import { Request } from "express";
import { getAccountIdForRequest } from "@/src/services/loginService";
import { getInventory } from "@/src/services/inventoryService";
import { Guild } from "@/src/models/guildModel";
import { IInventoryDatabaseDocument } from "../types/inventoryTypes/inventoryTypes";
export const getGuildForRequest = async (req: Request) => {
const accountId = await getAccountIdForRequest(req);
const inventory = await getInventory(accountId);
return await getGuildForRequestEx(req, inventory);
};
export const getGuildForRequestEx = async (req: Request, inventory: IInventoryDatabaseDocument) => {
const guildId = req.query.guildId as string;
if (!inventory.GuildId || inventory.GuildId.toString() != guildId) {
throw new Error("Account is not in the guild that it has sent a request for");
}
const guild = await Guild.findOne({ _id: guildId });
if (!guild) {
throw new Error("Account thinks it is a in guild that doesn't exist");
throw new Error("Account thinks it is in a guild that doesn't exist");
}
return guild;
};

View File

@ -11,10 +11,7 @@ export interface IGuildDatabase extends IGuild {
DojoComponents?: IDojoComponentDatabase[];
DojoCapacity: number;
DojoEnergy: number;
}
export interface ICreateGuildRequest {
guildName: string;
TechProjects?: ITechProjectDatabase[];
}
export interface IDojoClient {
@ -49,3 +46,15 @@ export interface IDojoComponentDatabase
pi?: Types.ObjectId;
CompletionTime?: Date;
}
export interface ITechProjectClient {
ItemType: string;
ReqCredits: number;
ReqItems: IMiscItem[];
State: number; // 0 = pending, 1 = complete
CompletionDate?: IMongoDate;
}
export interface ITechProjectDatabase extends Omit<ITechProjectClient, "CompletionDate"> {
CompletionDate?: Date;
}

View File

@ -460,10 +460,7 @@ export interface IFlavourItem {
ItemType: string;
}
export interface IMiscItem {
ItemCount: number;
ItemType: string;
}
export type IMiscItem = ITypeCount;
export interface ICrewShipWeapon {
PILOT: ICrewShipPilotWeapon;