Skip to content
Open
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
4 changes: 4 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ jobs:
VITE_ENV='test' \
REACT_APP_BACKEND_BASE_URL=$BACKEND_BASE_URL_TEST \
REACT_APP_SLACK_CLIENT_ID=$SLACK_CLIENT_ID_TEST \
VITE_GOOGLE_PICKER_API_KEY=$VITE_GOOGLE_PICKER_API_KEY \
VITE_GOOGLE_APP_ID=$VITE_GOOGLE_APP_ID \
NODE_ENV='staging' \
npm run build
- run:
Expand Down Expand Up @@ -165,6 +167,8 @@ jobs:
command: |
REACT_APP_BACKEND_BASE_URL=$APP_SLACK_BACKEND_BASE_URL_PROD \
REACT_APP_SLACK_CLIENT_ID=$SLACK_CLIENT_ID_PROD \
VITE_GOOGLE_PICKER_API_KEY=$VITE_GOOGLE_PICKER_API_KEY \
VITE_GOOGLE_APP_ID=$VITE_GOOGLE_APP_ID \
NODE_ENV='production' \
npm run build
- publish
Expand Down
6 changes: 6 additions & 0 deletions apps/drive-integration/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,9 @@ VITE_ENABLE_MOCK_EDIT_MODAL=

# Frontend (Vite): opt in to a local Agents API during development.
VITE_LOCAL_AGENTS_API_BASE_URL=

# Frontend (Vite): Google Picker API key (from GCP > APIs & Services > Credentials > Drive Integration API key).
VITE_GOOGLE_PICKER_API_KEY=

# Frontend (Vite): Google Cloud project number (991777691184 for the Contentful Google Docs App project).
VITE_GOOGLE_APP_ID=
4 changes: 2 additions & 2 deletions apps/drive-integration/src/hooks/useGoogleDocPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ type UseGoogleDocsPickerOptions = {
onCancel?: () => void;
};

const GOOGLE_PICKER_API_KEY = '';
const GOOGLE_PICKER_API_KEY = import.meta.env.VITE_GOOGLE_PICKER_API_KEY ?? '';

const GOOGLE_APP_ID = 1;
const GOOGLE_APP_ID = import.meta.env.VITE_GOOGLE_APP_ID ?? '';

// These are already exposed by google in the network even if they were hidden as environment variables
// and google acknowledges that these are okay to be public and that restrictions come from defining the
Expand Down
16 changes: 16 additions & 0 deletions apps/drive-integration/src/hooks/useWorkflowAgent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,14 @@ const getBackendWorkflowFailureReason = (runData: AgentRunData): WorkflowFailure
return WorkflowFailureReason.GOOGLE_DRIVE_AUTH_EXPIRED;
}

if (workflowFailure.code === WorkflowFailureReason.GOOGLE_DOCS_NOT_FOUND) {
return WorkflowFailureReason.GOOGLE_DOCS_NOT_FOUND;
}

if (workflowFailure.code === WorkflowFailureReason.AI_SERVICE_UNAVAILABLE) {
return WorkflowFailureReason.AI_SERVICE_UNAVAILABLE;
}

if (workflowFailure.code === WorkflowFailureReason.GENERIC) {
return WorkflowFailureReason.GENERIC;
}
Expand All @@ -138,6 +146,14 @@ const getWorkflowFailureMessage = (
return ERROR_MESSAGES.GOOGLE_DRIVE_AUTH_ERROR;
}

if (failureReason === WorkflowFailureReason.GOOGLE_DOCS_NOT_FOUND) {
return ERROR_MESSAGES.GOOGLE_DOCS_NOT_FOUND;
}

if (failureReason === WorkflowFailureReason.AI_SERVICE_UNAVAILABLE) {
return ERROR_MESSAGES.AI_SERVICE_UNAVAILABLE;
}

return getRunErrorMessage(runData);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,30 @@ export const ModalOrchestrator = forwardRef<ModalOrchestratorHandle, ModalOrches
return;
}

if (
error instanceof WorkflowRunError &&
error.reason === WorkflowFailureReason.GOOGLE_DOCS_NOT_FOUND
) {
setPreviewErrorState({
reason: WorkflowFailureReason.GOOGLE_DOCS_NOT_FOUND,
title: 'Document not found',
message: ERROR_MESSAGES.GOOGLE_DOCS_NOT_FOUND,
});
return;
}

if (
error instanceof WorkflowRunError &&
error.reason === WorkflowFailureReason.AI_SERVICE_UNAVAILABLE
) {
setPreviewErrorState({
reason: WorkflowFailureReason.AI_SERVICE_UNAVAILABLE,
title: 'AI service temporarily unavailable',
message: ERROR_MESSAGES.AI_SERVICE_UNAVAILABLE,
});
return;
}

setPreviewErrorState({
reason: WorkflowFailureReason.GENERIC,
title: 'Unable to generate preview',
Expand Down
2 changes: 2 additions & 0 deletions apps/drive-integration/src/types/workflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ export enum RunStatus {
export enum WorkflowFailureReason {
GENERIC = 'generic',
GOOGLE_DRIVE_AUTH_EXPIRED = 'google-drive-auth-expired',
GOOGLE_DOCS_NOT_FOUND = 'google-docs-not-found',
AI_SERVICE_UNAVAILABLE = 'ai-service-unavailable',
}

export interface WorkflowFailure {
Expand Down
4 changes: 4 additions & 0 deletions apps/drive-integration/src/utils/constants/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ export const ERROR_MESSAGES = {
GENERIC_ERROR: 'This preview could not be completed. Please start again.',
GOOGLE_DRIVE_AUTH_ERROR:
'Your Drive connection has expired or is no longer valid. Reconnect your account to continue generating a preview.',
GOOGLE_DOCS_NOT_FOUND:
'Google Doc not found. Make sure the document exists and your Google account has access to it.',
AI_SERVICE_UNAVAILABLE:
'The AI service is temporarily unavailable. Please try again in a few minutes.',
} as const;

export const SUCCESS_MESSAGES = {
Expand Down
Loading