mirror of
https://github.com/marcogll/AnchorOS.git
synced 2026-03-15 14:24:27 +00:00
Fix JSON parsing error in Google Calendar initialization
- Add try-catch for JSON.parse with better error handling - Validate credentials structure before use - Add detailed error logging for debugging - Prevent build failure from invalid GOOGLE_SERVICE_ACCOUNT_JSON Fixes SyntaxError during Next.js build process
This commit is contained in:
@@ -46,7 +46,19 @@ class GoogleCalendarService {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const credentials = JSON.parse(serviceAccountJson) as ServiceAccountConfig;
|
let credentials: ServiceAccountConfig;
|
||||||
|
|
||||||
|
try {
|
||||||
|
credentials = JSON.parse(serviceAccountJson) as ServiceAccountConfig;
|
||||||
|
} catch (jsonError) {
|
||||||
|
console.error('GoogleCalendar: Failed to parse GOOGLE_SERVICE_ACCOUNT_JSON', jsonError);
|
||||||
|
console.error('GoogleCalendar: Service account JSON value:', serviceAccountJson);
|
||||||
|
throw new Error('Invalid GOOGLE_SERVICE_ACCOUNT_JSON format. Please check environment variable.');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!credentials.type || !credentials.project_id || !credentials.private_key) {
|
||||||
|
throw new Error('Invalid GOOGLE_SERVICE_ACCOUNT_JSON: Missing required fields');
|
||||||
|
}
|
||||||
|
|
||||||
const auth = new google.auth.GoogleAuth({
|
const auth = new google.auth.GoogleAuth({
|
||||||
credentials,
|
credentials,
|
||||||
|
|||||||
Reference in New Issue
Block a user