Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion .github/workflows/coderabbit-auto-fix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,9 @@ jobs:
/^[[:space:]]*\n[[:space:]]*$/D
}')

DETAILS_MARKERS=$(printf '%s\n' "$CLEAN_COMMENT" | grep -cEi '<summary[^>]*>[^<]*(Suggested|Proposed|Prompt for AI Agents)' || true)
MARKDOWN_PROMPT_BLOCKS=$(printf '%s\n' "$CLEAN_COMMENT" | grep -cE 'Prompt for AI Agents' || true)

# Keep only Suggested fix + Prompt for AI Agents per issue; render as ClickUp-friendly fenced /code blocks.
cat > /tmp/cu_cr_clickup.pl <<'ENDPERL'
use strict;
Expand Down Expand Up @@ -327,8 +330,11 @@ jobs:
my @parts = split(/\n\n---\n\n/, $input);
my @blocks;
my $issue = 0;
my $total_chunks = 0;
my $fallback_chunks = 0;
for my $chunk (@parts) {
next unless $chunk =~ /\S/;
$total_chunks++;
my $fix = '';
my $prompt = '';
if ($chunk =~ m{<details[^>]*>\s*<summary[^>]*>[^<]*(?:Suggested\s+fix|Proposed\s+fix|Suggested\s+patch|💡\s*Proposed|🔧\s*Suggested|🐛\s*Proposed|♻️\s*Proposed)[^<]*</summary>(.*?)</details>}is) {
Expand All @@ -337,16 +343,32 @@ jobs:
if ($chunk =~ m{<details[^>]*>\s*<summary[^>]*>[^<]*(?:🤖\s*)?Prompt for AI Agents[^<]*</summary>(.*?)</details>}is) {
$prompt = $1;
}
# Fallback for markdown-only bodies (no <details>/<summary> wrapper).
if ($fix eq '' && $chunk =~ m{(?:^|\n)\h*(?:🛠️|💡|🔧|🐛|♻️)?\h*(?:Proposed|Suggested)\h+(?:fix|patch)\h*\n+\h*```(?:diff)?\n(.*?)\n\h*```}is) {
$fix = $1;
}
if ($prompt eq '' && $chunk =~ m{(?:^|\n)\h*(?:🤖\h*)?Prompt for AI Agents\h*\n+\h*```\n(.*?)\n\h*```}is) {
$prompt = $1;
}
my $piece = '';
$piece .= fence('Suggested fix', $fix) if $fix ne '';
$piece .= fence('Prompt for AI Agents', $prompt) if $prompt ne '';
if ($piece !~ /\S/) {
my $raw = strip_inner_html($chunk);
if ($raw ne '') {
$fallback_chunks++;
$piece .= fence('Review note (raw fallback)', $raw);
}
}
if ($piece =~ /\S/) {
$issue++;
push @blocks, "### Issue $issue\n\n" . $piece;
}
}
my $out = join("\n---\n\n", @blocks);
$out =~ s/\n{4,}/\n\n\n/g;
my $meta = "__PARSER_META__ total_chunks=$total_chunks fallback_chunks=$fallback_chunks issue_count=$issue";
print $meta . "\n";
print $out;
ENDPERL
sed -i 's/^[[:space:]]*//' /tmp/cu_cr_clickup.pl
Expand All @@ -360,16 +382,23 @@ jobs:
fi
fi

PARSER_META=$(printf '%s\n' "$CLEAN_COMMENT" | grep -m1 '^__PARSER_META__' || true)
if [ -n "$PARSER_META" ]; then
CLEAN_COMMENT=$(printf '%s\n' "$CLEAN_COMMENT" | sed '/^__PARSER_META__/d')
fi

ISSUE_COUNT=$(printf '%s\n' "$CLEAN_COMMENT" | grep -oE '### Issue [0-9]+' | wc -l | tr -d '[:space:]')
echo "issue_count=${ISSUE_COUNT}" >> "$GITHUB_OUTPUT"
echo "Formatted ClickUp payload: ${ISSUE_COUNT} issue block(s) (### Issue headings)."

{
echo "## CodeRabbit → ClickUp"
echo ""
echo "| Metric | Value |"
echo "|--------|-------|"
echo "| CodeRabbit PR comments matched (this review) | ${CLICKUP_MATCH_COUNT:-0} |"
echo "| `<summary...>` markers in source text | ${DETAILS_MARKERS:-0} |"
echo "| `Prompt for AI Agents` mentions in source text | ${MARKDOWN_PROMPT_BLOCKS:-0} |"
echo "| Parser meta | ${PARSER_META:-n/a} |"
echo "| Issues formatted for ClickUp (\`### Issue N\`) | ${ISSUE_COUNT} |"
echo ""
echo "Multiple findings from one CodeRabbit submission should appear as separate \`### Issue 1\`, \`### Issue 2\`, … in a single task comment."
Expand Down
37 changes: 37 additions & 0 deletions frontend/src/coderabbitManualPrProbe.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/**
* TEMPORARY — manual PR probe only: intentional bad patterns so CodeRabbit can surface multiple findings.
* Delete this file after you finish testing the CodeRabbit → ClickUp workflow.
*/

import { useMemo } from 'react';

const UNUSED_PROBE_CONST = 'never-read';
Comment on lines +6 to +8

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Remove unused import and dead constant from modified frontend source.

useMemo and UNUSED_PROBE_CONST are unused and violate the frontend strict rules for changed files.

Proposed fix
-import { useMemo } from 'react';
-
-const UNUSED_PROBE_CONST = 'never-read';

As per coding guidelines, "Frontend React code must not introduce or leave unused variables, imports, or parameters in modified files."

📝 Committable suggestion

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

Suggested change
import { useMemo } from 'react';
const UNUSED_PROBE_CONST = 'never-read';
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@frontend/src/coderabbitManualPrProbe.js` around lines 6 - 8, Remove the
unused import and dead constant: delete the unused "useMemo" import from the
top-level import list and remove the "UNUSED_PROBE_CONST" declaration; ensure no
other references to useMemo or UNUSED_PROBE_CONST exist (if any appear later,
replace with proper usage or remove those references) so the modified file no
longer contains unused symbols.


function validateProbeLabelA(label) {
if (!label || typeof label !== 'string') return false;
return label.trim().length > 0;
}

function validateProbeLabelB(label) {
if (!label || typeof label !== 'string') return false;
return label.trim().length > 0;
}

export async function fetchUserBadgeWrong(userId) {
console.log('probe: fetching badge', userId);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Remove ad-hoc console.log from frontend source before merge.

This should not remain in production frontend code paths.

Proposed fix
-  console.log('probe: fetching badge', userId);

As per coding guidelines, "frontend/src/**/*.{js,jsx}: No ad-hoc console.log / console.debug / console.info in production paths."

📝 Committable suggestion

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

Suggested change
console.log('probe: fetching badge', userId);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@frontend/src/coderabbitManualPrProbe.js` at line 21, Remove the ad-hoc
console.log call in frontend/src/coderabbitManualPrProbe.js (the statement
"console.log('probe: fetching badge', userId)") so no debug output leaks into
production; either delete the line or replace it with the approved logging
mechanism (e.g., a debug utility gated by environment/isDev) and ensure any
replaced call uses the project's centralized logger API and is disabled in
production.


const api_key = 'pk_live_000000000000000000000000';

const res = await fetch(`https://example.invalid/api/badge/${userId}?key=${api_key}`);
Comment on lines +23 to +25

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical | 🏗️ Heavy lift

Hardcoded API key in client code is a blocker.

Embedding pk_live_... in frontend source exposes credentials and violates client-secret handling rules. Move secret usage server-side and call a backend endpoint instead.

As per coding guidelines, "Frontend source code must not contain hardcoded secrets or long-lived tokens in client source."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@frontend/src/coderabbitManualPrProbe.js` around lines 23 - 25, The code
hardcodes api_key and calls
fetch(`https://example.invalid/api/badge/${userId}?key=${api_key}`); — remove
the client-side api_key and change the flow so the frontend (use the existing
userId) calls a new backend endpoint (e.g., /api/badge?userId=...) instead;
implement that backend handler to read the secret from environment/config and
proxy the request to https://example.invalid/api/badge/<userId> using the
server-side secret, then return the response to the frontend. Ensure api_key
variable and its usage in frontend are deleted and the server stores the secret
in env vars and logs no secret values.

const data = await res.json();

Comment on lines +25 to +27

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Route this request through frontend/src/services/api.js and add reachable failure handling.

This new network flow bypasses the repo API layer and has no res.ok/catch path. Failures currently propagate as unstructured runtime errors with no defined handling behavior.

Proposed fix
+import api from './services/api';
+
 export async function fetchUserBadgeWrong(userId) {
-  const api_key = 'pk_live_000000000000000000000000';
-
-  const res = await fetch(`https://example.invalid/api/badge/${userId}?key=${api_key}`);
-  const data = await res.json();
-
-  return data;
+  try {
+    const { data } = await api.get(`/badge/${userId}`);
+    return data;
+  } catch (error) {
+    throw new Error('Failed to fetch user badge');
+  }
 }

As per coding guidelines, "API calls go through frontend/src/services/api.js ... new calls must handle errors (.catch, user-visible error state, or equivalent)—not silent failures."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@frontend/src/coderabbitManualPrProbe.js` around lines 25 - 27, Replace the
direct fetch in coderabbitManualPrProbe.js with the centralized API client in
frontend/src/services/api.js (import the client, e.g. api.get or api.request)
instead of calling fetch(`https://.../badge/${userId}?key=${api_key}`); ensure
you check the response status (res.ok) and handle non-2xx responses by throwing
or returning a structured error, and wrap the call in try/catch to handle
network exceptions; surface the error to the caller or update a user-visible
error state rather than letting runtime exceptions propagate.

return data;
}

export function renderProbeRows(rows) {
return rows.map((row) => {
const okA = validateProbeLabelA(row.name);
const okB = validateProbeLabelB(row.slug);
return { label: row.name, okA, okB };
});
}