Async/await bug - The add_label function doesn't properly await its fetch call, which could lead to race conditions or silent failures when adding labels
Type comparison issue - The duplicate detection compares issue IDs (likely numbers) with string content, which may cause matching failures
Fragile duplicate parsing - The duplicate ID extraction logic could fail if the AI returns additional text beyond just the ID
Moderate Issues:
String replacement bug - Two instances where .replace(',', ', ') only replaces the first comma instead of all commas, affecting label formatting in AI prompts
Dead code - The type variable is still declared but no longer used after refactoring
Minor Issues:
Grammar error - Template text changed from "Any other" to "Anything other" (incorrect grammar)
Typo - "formated" should be "formatted" in the system prompt
Positive Changes:
Good refactoring from a single type tool to a more flexible add_label tool that supports multiple labels
Improved configurability with environment variables for label names
Better duplicate detection by including the current issue's ID in the prompt
More explicit AI instructions with numbered steps
The changes represent a solid improvement in functionality, but the async handling bug and string replacement issues should be addressed before merging to production.
## Summary
I've identified **8 issues** in this code review:
### Critical Issues:
1. **Async/await bug** - The `add_label` function doesn't properly await its fetch call, which could lead to race conditions or silent failures when adding labels
2. **Type comparison issue** - The duplicate detection compares issue IDs (likely numbers) with string content, which may cause matching failures
3. **Fragile duplicate parsing** - The duplicate ID extraction logic could fail if the AI returns additional text beyond just the ID
### Moderate Issues:
4. **String replacement bug** - Two instances where `.replace(',', ', ')` only replaces the first comma instead of all commas, affecting label formatting in AI prompts
5. **Dead code** - The `type` variable is still declared but no longer used after refactoring
### Minor Issues:
6. **Grammar error** - Template text changed from "Any other" to "Anything other" (incorrect grammar)
7. **Typo** - "formated" should be "formatted" in the system prompt
### Positive Changes:
- Good refactoring from a single `type` tool to a more flexible `add_label` tool that supports multiple labels
- Improved configurability with environment variables for label names
- Better duplicate detection by including the current issue's ID in the prompt
- More explicit AI instructions with numbered steps
The changes represent a solid improvement in functionality, but the async handling bug and string replacement issues should be addressed before merging to production.
The add_label function doesn't await the fetch call, which means errors may not be properly handled. The function is declared as async but doesn't await the promise, potentially causing race conditions or silent failures.
The add_label function doesn't await the fetch call, which means errors may not be properly handled. The function is declared as async but doesn't await the promise, potentially causing race conditions or silent failures.
String replacement issue: Using .replace(',', ', ') only replaces the first comma. This should be .replace(/,/g, ', ') to replace all commas with comma-space for proper formatting.
String replacement issue: Using `.replace(',', ', ')` only replaces the first comma. This should be `.replace(/,/g, ', ')` to replace all commas with comma-space for proper formatting.
Potential type mismatch in duplicate detection: The code compares id === hasDuplicates.trim() but issue IDs are typically numbers while hasDuplicates is a string. This comparison may fail if strict type checking is involved. Consider parsing the ID or ensuring type consistency.
Potential type mismatch in duplicate detection: The code compares `id === hasDuplicates.trim()` but issue IDs are typically numbers while hasDuplicates is a string. This comparison may fail if strict type checking is involved. Consider parsing the ID or ensuring type consistency.
The duplicate detection logic could fail if the AI returns the ID with additional text. Consider using a more robust parsing approach like parseInt(hasDuplicates) or regex extraction to handle edge cases.
The duplicate detection logic could fail if the AI returns the ID with additional text. Consider using a more robust parsing approach like `parseInt(hasDuplicates)` or regex extraction to handle edge cases.
This code review identified 8 issues that should be addressed in the refactoring changes:
Critical Issues:
Security vulnerability (line 110): Direct string interpolation of user-provided label values into JSON could break the JSON structure or introduce injection vulnerabilities
Race condition risk (line 107): The add_label function doesn't await its fetch call, potentially causing silent failures and incorrect label application
Bugs:
3. Type mismatch (line 185): Comparison between numeric IDs and string values in duplicate detection may fail
4. String replacement bug (lines 119, 122): Only replaces first comma instead of all commas in label lists
Code Quality:
5. Unused variable (line 46): The type variable is declared but never used after refactoring
6. Typo (line 123): "formated" should be "formatted"
7. Inconsistent null safety (line 39): Mixed use of optional chaining patterns
Positive Changes:
Good refactoring from hardcoded type labels to configurable environment variables
Improved flexibility with LABELS_REQ and LABELS_OPT configuration
Better separation of concerns with the add_label tool
Enhanced duplicate detection with more specific prompt instructions
Version bump appropriately reflects the changes
The refactoring direction is solid, but the issues identified (especially the security concern and async handling) should be addressed before merging.
## Review Summary
This code review identified **8 issues** that should be addressed in the refactoring changes:
**Critical Issues:**
1. **Security vulnerability** (line 110): Direct string interpolation of user-provided label values into JSON could break the JSON structure or introduce injection vulnerabilities
2. **Race condition risk** (line 107): The `add_label` function doesn't await its fetch call, potentially causing silent failures and incorrect label application
**Bugs:**
3. **Type mismatch** (line 185): Comparison between numeric IDs and string values in duplicate detection may fail
4. **String replacement bug** (lines 119, 122): Only replaces first comma instead of all commas in label lists
**Code Quality:**
5. **Unused variable** (line 46): The `type` variable is declared but never used after refactoring
6. **Typo** (line 123): "formated" should be "formatted"
7. **Inconsistent null safety** (line 39): Mixed use of optional chaining patterns
**Positive Changes:**
- Good refactoring from hardcoded type labels to configurable environment variables
- Improved flexibility with `LABELS_REQ` and `LABELS_OPT` configuration
- Better separation of concerns with the `add_label` tool
- Enhanced duplicate detection with more specific prompt instructions
- Version bump appropriately reflects the changes
The refactoring direction is solid, but the issues identified (especially the security concern and async handling) should be addressed before merging.
Array access without null safety: The code accesses issueData.labels[0]?.name but doesn't check if the array exists before checking length. While the optional chaining on labels?.[0] is safe, consider using issueData.labels?.[0]?.name for consistency with the length check pattern.
Array access without null safety: The code accesses `issueData.labels[0]?.name` but doesn't check if the array exists before checking length. While the optional chaining on `labels?.[0]` is safe, consider using `issueData.labels?.[0]?.name` for consistency with the length check pattern.
Unused variable 'type' is still declared but never used after refactoring. This variable should be removed from the declaration since the type-based labeling was replaced with the add_label tool.
Unused variable 'type' is still declared but never used after refactoring. This variable should be removed from the declaration since the type-based labeling was replaced with the add_label tool.
The add_label function doesn't await the fetch call. While the function is declared as async, the fetch promise is not awaited, which means errors may not be properly handled and could cause race conditions. Consider using 'await' before the fetch call to ensure proper error handling and sequencing.
The add_label function doesn't await the fetch call. While the function is declared as async, the fetch promise is not awaited, which means errors may not be properly handled and could cause race conditions. Consider using 'await' before the fetch call to ensure proper error handling and sequencing.
Security concern: The label value from args.label is directly interpolated into a JSON string without escaping. If the label contains special characters like quotes, it could break the JSON structure. Use JSON.stringify() instead: body: JSON.stringify({labels: [args.label]})
Security concern: The label value from args.label is directly interpolated into a JSON string without escaping. If the label contains special characters like quotes, it could break the JSON structure. Use JSON.stringify() instead: `body: JSON.stringify({labels: [args.label]})`
String replacement issue: Using .replace(',', ', ') only replaces the first comma. This should be .replace(/,/g, ', ') to replace all commas with comma-space for proper formatting of the labels list in the prompt.
String replacement issue: Using `.replace(',', ', ')` only replaces the first comma. This should be `.replace(/,/g, ', ')` to replace all commas with comma-space for proper formatting of the labels list in the prompt.
Same string replacement issue: .replace(',', ', ') only replaces the first comma. Should use .replace(/,/g, ', ') to replace all commas for proper formatting of the optional labels list.
Same string replacement issue: `.replace(',', ', ')` only replaces the first comma. Should use `.replace(/,/g, ', ')` to replace all commas for proper formatting of the optional labels list.
Potential type mismatch in duplicate detection: The code compares id === hasDuplicates.trim() where issue IDs are typically numbers while hasDuplicates is a string. This comparison may fail with strict type checking. Consider using id.toString() === hasDuplicates.trim() or id === parseInt(hasDuplicates) to ensure type consistency.
Potential type mismatch in duplicate detection: The code compares `id === hasDuplicates.trim()` where issue IDs are typically numbers while hasDuplicates is a string. This comparison may fail with strict type checking. Consider using `id.toString() === hasDuplicates.trim()` or `id === parseInt(hasDuplicates)` to ensure type consistency.
This update (v0.1.0 → v0.1.1) represents a significant refactoring of the AI ticket refinement system with several improvements:
Positive Changes:
Better configurability: Moving hardcoded labels to environment variables (LABELS_DUPE, LABEL_ENABLED, LABELS_REQ, LABELS_OPT) makes the system more flexible
Improved AI workflow: Replacing the single type tool with a more flexible add_label tool allows for multi-dimensional categorization
Enhanced duplicate detection: Adding the issue ID to the duplicate check and using "NONE" as an explicit response improves clarity
Better prompts: The updated system prompts provide clearer instructions and better context
Critical Issues Found:
Security vulnerability (lines 110, 194): Direct string interpolation in JSON construction could lead to injection attacks if labels contain quotes or special characters
Race condition risk (line 107): Multiple async label additions without proper synchronization could cause issues
Moderate Concerns:
4. Type coercion ambiguity (line 185): Using == instead of explicit type conversion makes the code less maintainable
5. Duplicate detection logic (line 181): Including the current issue's ID in the comparison input could confuse the AI
The refactoring is well-intentioned and improves the system's flexibility, but the security issue with JSON construction should be addressed before deployment. The race condition with label additions may also cause intermittent issues in production.
## Overall Review Summary
This update (v0.1.0 → v0.1.1) represents a significant refactoring of the AI ticket refinement system with several improvements:
**Positive Changes:**
- **Better configurability**: Moving hardcoded labels to environment variables (`LABELS_DUPE`, `LABEL_ENABLED`, `LABELS_REQ`, `LABELS_OPT`) makes the system more flexible
- **Improved AI workflow**: Replacing the single `type` tool with a more flexible `add_label` tool allows for multi-dimensional categorization
- **Enhanced duplicate detection**: Adding the issue ID to the duplicate check and using "NONE" as an explicit response improves clarity
- **Better prompts**: The updated system prompts provide clearer instructions and better context
**Critical Issues Found:**
1. **Security vulnerability** (lines 110, 194): Direct string interpolation in JSON construction could lead to injection attacks if labels contain quotes or special characters
2. **Race condition risk** (line 107): Multiple async label additions without proper synchronization could cause issues
3. **Missing await** (line 109): The fetch call isn't awaited, potentially causing silent failures
**Moderate Concerns:**
4. **Type coercion ambiguity** (line 185): Using `==` instead of explicit type conversion makes the code less maintainable
5. **Duplicate detection logic** (line 181): Including the current issue's ID in the comparison input could confuse the AI
The refactoring is well-intentioned and improves the system's flexibility, but the security issue with JSON construction should be addressed before deployment. The race condition with label additions may also cause intermittent issues in production.
Race condition risk: The add_label function is called multiple times in the AI tool execution flow, but there's no guarantee of execution order or completion. If the AI calls add_label multiple times rapidly, the labels array may not be properly synchronized with the actual API calls. Consider awaiting all label operations or using a queue.
Race condition risk: The add_label function is called multiple times in the AI tool execution flow, but there's no guarantee of execution order or completion. If the AI calls add_label multiple times rapidly, the labels array may not be properly synchronized with the actual API calls. Consider awaiting all label operations or using a queue.
The fetch call inside add_label is not awaited before returning. While the function is async and returns the promise, this could cause issues with error handling and sequencing. Consider using await fetch(...) to ensure proper error propagation.
The fetch call inside add_label is not awaited before returning. While the function is async and returns the promise, this could cause issues with error handling and sequencing. Consider using `await fetch(...)` to ensure proper error propagation.
Security concern: The label value from args.label is directly interpolated into a JSON string without escaping. If the label contains special characters like quotes, it could break the JSON structure or cause injection issues. Use JSON.stringify({labels: [args.label]}) instead of template literals.
Security concern: The label value from args.label is directly interpolated into a JSON string without escaping. If the label contains special characters like quotes, it could break the JSON structure or cause injection issues. Use `JSON.stringify({labels: [args.label]})` instead of template literals.
String replacement issue: Using .replaceAll(',', ', ') is correct, but note this requires Node.js 15+. If supporting older versions, use .replace(/,/g, ', ') instead for compatibility.
String replacement issue: Using `.replaceAll(',', ', ')` is correct, but note this requires Node.js 15+. If supporting older versions, use `.replace(/,/g, ', ')` instead for compatibility.
The duplicate detection prompt now includes the current issue's ID in the input, which could confuse the AI if it returns its own ID as a duplicate. Consider adding explicit instructions to the system prompt to ignore the first ID or exclude the current issue from the search results.
The duplicate detection prompt now includes the current issue's ID in the input, which could confuse the AI if it returns its own ID as a duplicate. Consider adding explicit instructions to the system prompt to ignore the first ID or exclude the current issue from the search results.
Type coercion in duplicate detection: Using loose equality id == hasDuplicates.trim() is intentional for type coercion, but this could mask bugs. Consider being explicit with id === parseInt(hasDuplicates.trim(), 10) or id.toString() === hasDuplicates.trim() to make the type conversion clear and handle NaN cases.
Type coercion in duplicate detection: Using loose equality `id == hasDuplicates.trim()` is intentional for type coercion, but this could mask bugs. Consider being explicit with `id === parseInt(hasDuplicates.trim(), 10)` or `id.toString() === hasDuplicates.trim()` to make the type conversion clear and handle NaN cases.
Inconsistent JSON construction: This line correctly uses template literal for the label variable, but it has the same security issue as line 110. For consistency and safety, use JSON.stringify({labels: [labelDupe]}) throughout the codebase.
Inconsistent JSON construction: This line correctly uses template literal for the label variable, but it has the same security issue as line 110. For consistency and safety, use `JSON.stringify({labels: [labelDupe]})` throughout the codebase.
ztimson marked this conversation as resolved
ztimson
merged commit f543e08e36 into master2026-01-14 13:22:33 -05:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Summary
I've identified 8 issues in this code review:
Critical Issues:
add_labelfunction doesn't properly await its fetch call, which could lead to race conditions or silent failures when adding labelsModerate Issues:
.replace(',', ', ')only replaces the first comma instead of all commas, affecting label formatting in AI promptstypevariable is still declared but no longer used after refactoringMinor Issues:
Positive Changes:
typetool to a more flexibleadd_labeltool that supports multiple labelsThe changes represent a solid improvement in functionality, but the async handling bug and string replacement issues should be addressed before merging to production.
Grammar error: "Anything other" should be "Any other". The original text was correct.
@@ -40,3 +44,3 @@// Gather readme & templatelet title = '', type = '', readme = '', readmeP = path.join(process.cwd(), 'README.md');let title = '', type = '', labels = [], readme = '', readmeP = path.join(process.cwd(), 'README.md');if(fs.existsSync(readmeP)) readme = fs.readFileSync(readmeP, 'utf-8');Unused variable 'type' is still declared but never used after refactoring. It should be removed from the declaration on line 46.
@@ -103,0 +104,4 @@description: 'Add a label to the ticket',args: {label: {type: 'string', description: 'Label name', required: true}},fn: async (args) => {labels.push(args.label);The add_label function doesn't await the fetch call, which means errors may not be properly handled. The function is declared as async but doesn't await the promise, potentially causing race conditions or silent failures.
@@ -109,2 +118,2 @@3. Call \`title\` tool EXACTLY ONCE in format: "[Module] - [Verb] [subject]" (example: Storage - fix file uploads)4. Output formatted markdown matching template structure below1. Call \`title\` tool EXACTLY ONCE in format: "[Module] - [Verb] [subject]" (example: Storage - fix file uploads)2. Identify one label from each group which best applies to the ticket: ${labelsReq.replace(',', ', ')}String replacement issue: Using
.replace(',', ', ')only replaces the first comma. This should be.replace(/,/g, ', ')to replace all commas with comma-space for proper formatting.@@ -111,0 +119,4 @@2. Identify one label from each group which best applies to the ticket: ${labelsReq.replace(',', ', ')}3. Call the \`add_label\` tool ONCE FOR EVERY LABEL identified in the previous step4. Filter the following labels to any that apply to this ticket: ${labelsOpt.replace(',', ', ')}5. Call the \`add_label\` tool ONCE FOR EVERY LABEL identified in the previous stepSame string replacement issue:
.replace(',', ', ')only replaces the first comma. Should use.replace(/,/g, ', ')to replace all commas.@@ -111,0 +120,4 @@3. Call the \`add_label\` tool ONCE FOR EVERY LABEL identified in the previous step4. Filter the following labels to any that apply to this ticket: ${labelsOpt.replace(',', ', ')}5. Call the \`add_label\` tool ONCE FOR EVERY LABEL identified in the previous step6. Output the new ticket description in formated markdown matching the following rules:Typo in prompt: "formated markdown" should be "formatted markdown".
@@ -170,3 +183,3 @@}))?.pop()?.content;// Handle duplicatesif(!!hasDuplicates && (dupeId = dupeIds.find(id => new RegExp(`\\b${id}\\b`, 'm').test(hasDuplicates)))) {if(hasDuplicates && hasDuplicates !== 'NONE' && (dupeId = dupeIds.find(id => id === hasDuplicates.trim()))) {Potential type mismatch in duplicate detection: The code compares
id === hasDuplicates.trim()but issue IDs are typically numbers while hasDuplicates is a string. This comparison may fail if strict type checking is involved. Consider parsing the ID or ensuring type consistency.The duplicate detection logic could fail if the AI returns the ID with additional text. Consider using a more robust parsing approach like
parseInt(hasDuplicates)or regex extraction to handle edge cases.Review Summary
This code review identified 8 issues that should be addressed in the refactoring changes:
Critical Issues:
add_labelfunction doesn't await its fetch call, potentially causing silent failures and incorrect label applicationBugs:
3. Type mismatch (line 185): Comparison between numeric IDs and string values in duplicate detection may fail
4. String replacement bug (lines 119, 122): Only replaces first comma instead of all commas in label lists
Code Quality:
5. Unused variable (line 46): The
typevariable is declared but never used after refactoring6. Typo (line 123): "formated" should be "formatted"
7. Inconsistent null safety (line 39): Mixed use of optional chaining patterns
Positive Changes:
LABELS_REQandLABELS_OPTconfigurationadd_labeltoolThe refactoring direction is solid, but the issues identified (especially the security concern and async handling) should be addressed before merging.
@@ -33,3 +37,3 @@else throw new Error(`${resp.status} ${await resp.text()}`);});if(issueData.labels?.[0] !== 1 || issueData.labels?.[0]?.name !== 'Review/AI') {if(issueData.labels?.length !== 1 || issueData.labels[0]?.name !== labelEnabled) {Array access without null safety: The code accesses
issueData.labels[0]?.namebut doesn't check if the array exists before checking length. While the optional chaining onlabels?.[0]is safe, consider usingissueData.labels?.[0]?.namefor consistency with the length check pattern.@@ -40,3 +44,3 @@// Gather readme & templatelet title = '', type = '', readme = '', readmeP = path.join(process.cwd(), 'README.md');let title = '', type = '', labels = [], readme = '', readmeP = path.join(process.cwd(), 'README.md');if(fs.existsSync(readmeP)) readme = fs.readFileSync(readmeP, 'utf-8');Unused variable 'type' is still declared but never used after refactoring. This variable should be removed from the declaration since the type-based labeling was replaced with the add_label tool.
@@ -103,0 +104,4 @@description: 'Add a label to the ticket',args: {label: {type: 'string', description: 'Label name', required: true}},fn: async (args) => {labels.push(args.label);The add_label function doesn't await the fetch call. While the function is declared as async, the fetch promise is not awaited, which means errors may not be properly handled and could cause race conditions. Consider using 'await' before the fetch call to ensure proper error handling and sequencing.
@@ -103,0 +107,4 @@labels.push(args.label);fetch(`${git}/api/v1/repos/${owner}/${repo}/issues/${ticket}/labels`, {method: 'POST',headers: {'Authorization': `token ${auth}`, 'Content-Type': 'application/json'},Security concern: The label value from args.label is directly interpolated into a JSON string without escaping. If the label contains special characters like quotes, it could break the JSON structure. Use JSON.stringify() instead:
body: JSON.stringify({labels: [args.label]})@@ -109,2 +118,2 @@3. Call \`title\` tool EXACTLY ONCE in format: "[Module] - [Verb] [subject]" (example: Storage - fix file uploads)4. Output formatted markdown matching template structure below1. Call \`title\` tool EXACTLY ONCE in format: "[Module] - [Verb] [subject]" (example: Storage - fix file uploads)2. Identify one label from each group which best applies to the ticket: ${labelsReq.replace(',', ', ')}String replacement issue: Using
.replace(',', ', ')only replaces the first comma. This should be.replace(/,/g, ', ')to replace all commas with comma-space for proper formatting of the labels list in the prompt.@@ -111,0 +119,4 @@2. Identify one label from each group which best applies to the ticket: ${labelsReq.replace(',', ', ')}3. Call the \`add_label\` tool ONCE FOR EVERY LABEL identified in the previous step4. Filter the following labels to any that apply to this ticket: ${labelsOpt.replace(',', ', ')}5. Call the \`add_label\` tool ONCE FOR EVERY LABEL identified in the previous stepSame string replacement issue:
.replace(',', ', ')only replaces the first comma. Should use.replace(/,/g, ', ')to replace all commas for proper formatting of the optional labels list.@@ -111,0 +120,4 @@3. Call the \`add_label\` tool ONCE FOR EVERY LABEL identified in the previous step4. Filter the following labels to any that apply to this ticket: ${labelsOpt.replace(',', ', ')}5. Call the \`add_label\` tool ONCE FOR EVERY LABEL identified in the previous step6. Output the new ticket description in formated markdown matching the following rules:Typo in prompt: "formated markdown" should be "formatted markdown" (missing 't').
@@ -170,3 +183,3 @@}))?.pop()?.content;// Handle duplicatesif(!!hasDuplicates && (dupeId = dupeIds.find(id => new RegExp(`\\b${id}\\b`, 'm').test(hasDuplicates)))) {if(hasDuplicates && hasDuplicates !== 'NONE' && (dupeId = dupeIds.find(id => id === hasDuplicates.trim()))) {Potential type mismatch in duplicate detection: The code compares
id === hasDuplicates.trim()where issue IDs are typically numbers while hasDuplicates is a string. This comparison may fail with strict type checking. Consider usingid.toString() === hasDuplicates.trim()orid === parseInt(hasDuplicates)to ensure type consistency.Overall Review Summary
This update (v0.1.0 → v0.1.1) represents a significant refactoring of the AI ticket refinement system with several improvements:
Positive Changes:
LABELS_DUPE,LABEL_ENABLED,LABELS_REQ,LABELS_OPT) makes the system more flexibletypetool with a more flexibleadd_labeltool allows for multi-dimensional categorizationCritical Issues Found:
Moderate Concerns:
4. Type coercion ambiguity (line 185): Using
==instead of explicit type conversion makes the code less maintainable5. Duplicate detection logic (line 181): Including the current issue's ID in the comparison input could confuse the AI
The refactoring is well-intentioned and improves the system's flexibility, but the security issue with JSON construction should be addressed before deployment. The race condition with label additions may also cause intermittent issues in production.
@@ -103,0 +104,4 @@description: 'Add a label to the ticket',args: {label: {type: 'string', description: 'Label name', required: true}},fn: async (args) => {labels.push(args.label);Race condition risk: The add_label function is called multiple times in the AI tool execution flow, but there's no guarantee of execution order or completion. If the AI calls add_label multiple times rapidly, the labels array may not be properly synchronized with the actual API calls. Consider awaiting all label operations or using a queue.
@@ -103,0 +106,4 @@fn: async (args) => {labels.push(args.label);return await fetch(`${git}/api/v1/repos/${owner}/${repo}/issues/${ticket}/labels`, {method: 'POST',The fetch call inside add_label is not awaited before returning. While the function is async and returns the promise, this could cause issues with error handling and sequencing. Consider using
await fetch(...)to ensure proper error propagation.@@ -103,0 +107,4 @@labels.push(args.label);return await fetch(`${git}/api/v1/repos/${owner}/${repo}/issues/${ticket}/labels`, {method: 'POST',headers: {'Authorization': `token ${auth}`, 'Content-Type': 'application/json'},Security concern: The label value from args.label is directly interpolated into a JSON string without escaping. If the label contains special characters like quotes, it could break the JSON structure or cause injection issues. Use
JSON.stringify({labels: [args.label]})instead of template literals.@@ -109,2 +118,2 @@3. Call \`title\` tool EXACTLY ONCE in format: "[Module] - [Verb] [subject]" (example: Storage - fix file uploads)4. Output formatted markdown matching template structure below1. Call \`title\` tool EXACTLY ONCE in format: "[Module] - [Verb] [subject]" (example: Storage - fix file uploads)2. Identify one label from each group which best applies to the ticket: ${labelsReq.replaceAll(',', ', ')}String replacement issue: Using
.replaceAll(',', ', ')is correct, but note this requires Node.js 15+. If supporting older versions, use.replace(/,/g, ', ')instead for compatibility.@@ -167,3 +180,2 @@const dupes = search.map(t => `ID: ${t.id}\nTitle: ${t.title}\n\`\`\`markdown\n${t.body}\n\`\`\``).join('\n\n');const hasDuplicates = (await ai.language.ask(`${title}\n\`\`\`markdown\n${body}\n\`\`\``, {system: `Your job is to identify duplicates. Respond with the ID number of the duplicate or nothing if there are no matches \n\n${dupes}`const hasDuplicates = (await ai.language.ask(`ID: ${issueData.id}\nTitle: ${title}\n\`\`\`markdown\n${body}\n\`\`\``, {The duplicate detection prompt now includes the current issue's ID in the input, which could confuse the AI if it returns its own ID as a duplicate. Consider adding explicit instructions to the system prompt to ignore the first ID or exclude the current issue from the search results.
@@ -170,3 +183,3 @@}))?.pop()?.content;// Handle duplicatesif(!!hasDuplicates && (dupeId = dupeIds.find(id => new RegExp(`\\b${id}\\b`, 'm').test(hasDuplicates)))) {if(hasDuplicates && hasDuplicates !== 'NONE' && (dupeId = dupeIds.find(id => id == hasDuplicates.trim()))) {Type coercion in duplicate detection: Using loose equality
id == hasDuplicates.trim()is intentional for type coercion, but this could mask bugs. Consider being explicit withid === parseInt(hasDuplicates.trim(), 10)orid.toString() === hasDuplicates.trim()to make the type conversion clear and handle NaN cases.@@ -179,3 +192,3 @@method: 'POST',headers: {'Authorization': `token ${auth}`, 'Content-Type': 'application/json'},body: '{"labels":["Reviewed/Duplicate"]}'body: `{"labels":["${labelDupe}"]}`Inconsistent JSON construction: This line correctly uses template literal for the label variable, but it has the same security issue as line 110. For consistency and safety, use
JSON.stringify({labels: [labelDupe]})throughout the codebase.