Skip to content

Commit 2f00187

Browse files
sounmindsoobingclaude
committed
fix: address code review findings
- fetchUserSolutions: warn on truncated tree response - fetchPRSubmissions: warn when 100-file cap is hit - generateApproachAnalysis: wrap JSON.parse in try/catch - progressBar: clamp filled to barLength with Math.min Co-Authored-By: Soobin Bak <soobing@users.noreply.github.com> Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 9e9a118 commit 2f00187

3 files changed

Lines changed: 19 additions & 2 deletions

File tree

utils/learningComment.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function progressBar(completed, total, barLength = 7) {
3131
if (total === 0) {
3232
return "□".repeat(barLength);
3333
}
34-
const filled = Math.round((completed / total) * barLength);
34+
const filled = Math.min(Math.round((completed / total) * barLength), barLength);
3535
return "■".repeat(filled) + "□".repeat(barLength - filled);
3636
}
3737

utils/learningData.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@ export async function fetchUserSolutions(
6969

7070
const data = await response.json();
7171

72+
if (data.truncated) {
73+
console.warn(
74+
`[fetchUserSolutions] Tree response truncated for ${repoOwner}/${repoName}. Results may be incomplete.`
75+
);
76+
}
77+
7278
// Pattern: {problem-name}/{username}.{ext}
7379
// The path must have exactly two segments and the filename must be username.ext
7480
const usernamePattern = new RegExp(
@@ -121,6 +127,12 @@ export async function fetchPRSubmissions(
121127

122128
const files = await response.json();
123129

130+
if (files.length === 100) {
131+
console.warn(
132+
`[fetchPRSubmissions] PR #${prNumber} has 100+ files. Some submissions may be missed.`
133+
);
134+
}
135+
124136
// Pattern: {problem-name}/{username}.{ext}
125137
const usernamePattern = new RegExp(
126138
`^([^/]+)/${escapeRegExp(username)}\\.[^/]+$`

utils/openai.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,12 @@ ${truncatedContent}
244244
throw new Error("Empty response from OpenAI");
245245
}
246246

247-
const parsed = JSON.parse(content);
247+
let parsed;
248+
try {
249+
parsed = JSON.parse(content);
250+
} catch {
251+
throw new Error(`OpenAI returned invalid JSON: ${content.slice(0, 200)}`);
252+
}
248253

249254
return {
250255
matches: parsed.matches === true,

0 commit comments

Comments
 (0)