Skip to content
Merged
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
7 changes: 6 additions & 1 deletion src/mcp/tools/challenges/queryChallenges.tool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ export class QueryChallengesTool {
this.logger.error(
`Failed to fetch challenges from Topcoder API: ${challenges.statusText}`,
);
try {
this.logger.error(await challenges.json());

Choose a reason for hiding this comment

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

medium
correctness
Consider checking if challenges has a valid JSON response before attempting to parse it. This can prevent unnecessary exceptions and improve error handling.

} catch (e) {
this.logger.error('Failed to log challenge error');
}

// Return an error response if the API call fails
return {
Expand Down Expand Up @@ -108,7 +113,7 @@ export class QueryChallengesTool {
},
};
} catch (error) {
this.logger.error(`Error fetching challenges: ${error.message}`);
this.logger.error(`Error fetching challenges: ${error.message}`, error);

Choose a reason for hiding this comment

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

medium
security
Passing the entire error object to the logger can be beneficial for debugging as it may include additional context like stack traces. Ensure that the logger is configured to handle and securely store this information, especially if it contains sensitive data.

return {
content: [
{
Expand Down