-
Notifications
You must be signed in to change notification settings - Fork 449
fix: add reset db on command, expose error on e2e tests #1627
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
5d35c79
4dbd153
1af64ef
765f57f
28c61a2
dfa64c8
7229142
0a83f13
ab7c3a8
75cc67b
92658d1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,6 +24,7 @@ const OnboardingUpload = ({ onComplete }: OnboardingUploadProps) => { | |
| const [uploadedTaskId, setUploadedTaskId] = useState<string | null>(null); | ||
| const [shouldCreateFilter, setShouldCreateFilter] = useState(false); | ||
| const [isCreatingFilter, setIsCreatingFilter] = useState(false); | ||
| const [error, setError] = useState<string | null>(null); | ||
|
|
||
| const createFilterMutation = useCreateFilter(); | ||
| const updateOnboardingMutation = useUpdateOnboardingStateMutation(); | ||
|
|
@@ -63,6 +64,41 @@ const OnboardingUpload = ({ onComplete }: OnboardingUploadProps) => { | |
| matchingTask.status === "running" || | ||
| matchingTask.status === "processing"; | ||
|
|
||
| // Check if matching task failed or has error status | ||
| const failedTask = | ||
| matchingTask.status === "failed" || matchingTask.status === "error"; | ||
|
|
||
| // Check if any file inside the task failed | ||
| const filesArray = matchingTask.files | ||
| ? (Object.values(matchingTask.files) as { | ||
| status: string; | ||
| error?: string; | ||
| }[]) | ||
| : []; | ||
| const hasFailedFile = filesArray.some( | ||
| (file) => file.status === "failed" || file.status === "error", | ||
| ); | ||
|
|
||
| if (failedTask || hasFailedFile) { | ||
| let errorMessage = "Document ingestion failed. Please try again."; | ||
| if (matchingTask.error) { | ||
| errorMessage = matchingTask.error; | ||
| } else { | ||
| const failedFile = filesArray.find( | ||
| (file) => | ||
| (file.status === "failed" || file.status === "error") && file.error, | ||
| ); | ||
| if (failedFile?.error) { | ||
| errorMessage = failedFile.error; | ||
| } | ||
| } | ||
|
|
||
| setError(errorMessage); | ||
| setCurrentStep(null); | ||
| setUploadedTaskId(null); | ||
| return; | ||
|
Comment on lines
+96
to
+99
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Clear filter-intent state on failure to avoid retry cross-contamination. After a failed ingestion/upload, Suggested fix if (failedTask || hasFailedFile) {
let errorMessage = "Document ingestion failed. Please try again.";
@@
setError(errorMessage);
setCurrentStep(null);
setUploadedTaskId(null);
+ setShouldCreateFilter(false);
+ setUploadedFilename(null);
return;
}
@@
} catch (error) {
@@
// Reset on error
setCurrentStep(null);
setUploadedTaskId(null);
+ setShouldCreateFilter(false);
+ setUploadedFilename(null);
} finally {Also applies to: 251-253 🤖 Prompt for AI Agents |
||
| } | ||
|
|
||
| // If task is completed or has processed files, complete the onboarding step | ||
| if (!isTaskActive || (matchingTask.processed_files ?? 0) > 0) { | ||
| // Set to final step to show "Done" | ||
|
|
@@ -169,6 +205,7 @@ const OnboardingUpload = ({ onComplete }: OnboardingUploadProps) => { | |
|
|
||
| const performUpload = async (file: File) => { | ||
| setIsUploading(true); | ||
| setError(null); | ||
| try { | ||
| setCurrentStep(0); | ||
| const result = await uploadFile(file, true, true); // Pass createFilter=true | ||
|
|
@@ -193,6 +230,7 @@ const OnboardingUpload = ({ onComplete }: OnboardingUploadProps) => { | |
| const errorMessage = | ||
| error instanceof Error ? error.message : "Upload failed"; | ||
| console.error("Upload failed", errorMessage); | ||
| setError(errorMessage); | ||
|
|
||
| // Dispatch event that chat context can listen to | ||
| // This avoids circular dependency issues | ||
|
|
@@ -246,6 +284,25 @@ const OnboardingUpload = ({ onComplete }: OnboardingUploadProps) => { | |
| exit={{ opacity: 0, y: -24 }} | ||
| transition={{ duration: 0.4, ease: "easeInOut" }} | ||
| > | ||
| <AnimatePresence mode="wait"> | ||
| {error && ( | ||
| <motion.div | ||
| key="error" | ||
| initial={{ opacity: 1, y: 0, height: "auto" }} | ||
| exit={{ opacity: 0, y: -10, height: 0 }} | ||
| > | ||
| <div className="pb-6 flex items-center gap-4"> | ||
| <X className="w-4 h-4 text-destructive shrink-0" /> | ||
| <span | ||
| data-testid="onboarding-upload-error" | ||
| className="text-mmd text-muted-foreground" | ||
| > | ||
| {error} | ||
| </span> | ||
| </div> | ||
| </motion.div> | ||
| )} | ||
| </AnimatePresence> | ||
| <Button | ||
| size="sm" | ||
| variant="outline" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -54,14 +54,19 @@ export async function completeOnboarding( | |
| } | ||
|
|
||
| const isCompleted = await completedLocator.isVisible(); | ||
| const isFirstStep = await page.getByTestId("openai-llm-tab").isVisible(); | ||
|
|
||
| if (isCompleted) { | ||
| if (!reset) { | ||
| console.log("Onboarding already complete, skipping..."); | ||
| return; | ||
| } | ||
| if (isCompleted && !reset) { | ||
| console.log("Onboarding already complete, skipping..."); | ||
| return; | ||
| } | ||
|
|
||
| const needsRollback = reset && (isCompleted || !isFirstStep); | ||
|
|
||
| console.log("Onboarding complete and reset is true, rolling back..."); | ||
| if (needsRollback) { | ||
| console.log( | ||
| "Onboarding complete or not on the first step, and reset is true, rolling back...", | ||
| ); | ||
| const response = await page.request.post("/api/onboarding/rollback"); | ||
| if (!response.ok()) { | ||
| const text = await response.text(); | ||
|
|
@@ -141,9 +146,18 @@ export async function completeOnboarding( | |
| await page.getByTestId("onboarding-complete-button").click(); | ||
|
|
||
| await expect(page.getByText("Thinking")).toBeVisible(); | ||
| await expect(page.getByText("Done")).toBeVisible({ | ||
|
|
||
| const doneLocator = page.getByText("Done"); | ||
| const errorLocator = page.getByTestId("onboarding-error"); | ||
|
|
||
| await expect(doneLocator.or(errorLocator)).toBeVisible({ | ||
| timeout: isEmbedding ? 120000 : 60000, | ||
|
Comment on lines
+150
to
154
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Scope the Using Suggested fix- const doneLocator = page.getByText("Done");
+ const doneLocator = page.getByText(/^Done$/).last();
const errorLocator = page.getByTestId("onboarding-error");
@@
- const uploadDoneLocator = page.getByText("Done");
+ const uploadDoneLocator = page.getByText(/^Done$/).last();
const uploadErrorLocator = page.getByTestId("onboarding-upload-error");Also applies to: 199-203 🤖 Prompt for AI Agents |
||
| }); | ||
|
|
||
| if (await errorLocator.isVisible()) { | ||
| const errorText = await errorLocator.innerText(); | ||
| throw new Error(`Onboarding step failed: ${errorText}`); | ||
| } | ||
| }; | ||
|
|
||
| // 1. LLM configuration | ||
|
|
@@ -182,6 +196,17 @@ export async function completeOnboarding( | |
| path.join(__dirname, "../assets", "test-document.md"), | ||
| ); | ||
|
|
||
| await expect(page.getByText("Done")).toBeVisible({ timeout: 60000 }); | ||
| const uploadDoneLocator = page.getByText("Done"); | ||
| const uploadErrorLocator = page.getByTestId("onboarding-upload-error"); | ||
|
|
||
| await expect(uploadDoneLocator.or(uploadErrorLocator)).toBeVisible({ | ||
| timeout: 120000, | ||
| }); | ||
|
|
||
| if (await uploadErrorLocator.isVisible()) { | ||
| const errorText = await uploadErrorLocator.innerText(); | ||
| throw new Error(`Onboarding document upload failed: ${errorText}`); | ||
| } | ||
|
|
||
| await expect(page.getByTestId("onboarding-content")).toBeHidden(); | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a hard safety guard before deleting
OPENRAG_DATA_PATH.rm -rf "$$OPENRAG_DATA_PATH"currently trusts a raw env path. A mis-set value (e.g./,., or project root) can wipe unrelated data.🛡️ Suggested guard
📝 Committable suggestion
🤖 Prompt for AI Agents