mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-02-04 21:23:07 +00:00
fix: enhance error logging for JSON parsing in suggestions generation
- Added error logging for failed JSON parsing in the suggestions generation route to improve debugging capabilities. - This change ensures that any parsing errors are captured and logged, aiding in the identification of issues with AI response handling.
This commit is contained in:
@@ -3,10 +3,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import type { Request, Response } from "express";
|
import type { Request, Response } from "express";
|
||||||
import {
|
import { getSpecRegenerationStatus, getErrorMessage } from "../common.js";
|
||||||
getSpecRegenerationStatus,
|
|
||||||
getErrorMessage,
|
|
||||||
} from "../common.js";
|
|
||||||
|
|
||||||
export function createStatusHandler() {
|
export function createStatusHandler() {
|
||||||
return async (_req: Request, res: Response): Promise<void> => {
|
return async (_req: Request, res: Response): Promise<void> => {
|
||||||
|
|||||||
@@ -3,18 +3,15 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import type { Request, Response } from "express";
|
import type { Request, Response } from "express";
|
||||||
import {
|
import { getApiKey, getErrorMessage, logError } from "../common.js";
|
||||||
getApiKey,
|
|
||||||
getErrorMessage,
|
|
||||||
logError,
|
|
||||||
} from "../common.js";
|
|
||||||
|
|
||||||
export function createApiKeysHandler() {
|
export function createApiKeysHandler() {
|
||||||
return async (_req: Request, res: Response): Promise<void> => {
|
return async (_req: Request, res: Response): Promise<void> => {
|
||||||
try {
|
try {
|
||||||
res.json({
|
res.json({
|
||||||
success: true,
|
success: true,
|
||||||
hasAnthropicKey: !!getApiKey("anthropic") || !!process.env.ANTHROPIC_API_KEY,
|
hasAnthropicKey:
|
||||||
|
!!getApiKey("anthropic") || !!process.env.ANTHROPIC_API_KEY,
|
||||||
hasGoogleKey: !!getApiKey("google") || !!process.env.GOOGLE_API_KEY,
|
hasGoogleKey: !!getApiKey("google") || !!process.env.GOOGLE_API_KEY,
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -106,6 +106,8 @@ Format your response as JSON:
|
|||||||
throw new Error("No valid JSON found in response");
|
throw new Error("No valid JSON found in response");
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
// Log the parsing error for debugging
|
||||||
|
logger.error("Failed to parse suggestions JSON from AI response:", error);
|
||||||
// Return generic suggestions if parsing fails
|
// Return generic suggestions if parsing fails
|
||||||
events.emit("suggestions:event", {
|
events.emit("suggestions:event", {
|
||||||
type: "suggestions_complete",
|
type: "suggestions_complete",
|
||||||
|
|||||||
@@ -3,11 +3,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import type { Request, Response } from "express";
|
import type { Request, Response } from "express";
|
||||||
import {
|
import { getSuggestionsStatus, getErrorMessage, logError } from "../common.js";
|
||||||
getSuggestionsStatus,
|
|
||||||
getErrorMessage,
|
|
||||||
logError,
|
|
||||||
} from "../common.js";
|
|
||||||
|
|
||||||
export function createStatusHandler() {
|
export function createStatusHandler() {
|
||||||
return async (_req: Request, res: Response): Promise<void> => {
|
return async (_req: Request, res: Response): Promise<void> => {
|
||||||
|
|||||||
Reference in New Issue
Block a user