Skip to content

LLM-Driven Extraction of Unstructured Data — Built for API Deployments & ETL Pipeline Workflows

UN-3398 [FIX] Pre-populate connector form with schema defaults (#1913)

Kirtiman Mishra6383b103faf9
diff --git a/frontend/src/components/input-output/add-source/AddSource.jsx b/frontend/src/components/input-output/add-source/AddSource.jsx
index 9cdd757b8..e55c9b529 100644
--- a/frontend/src/components/input-output/add-source/AddSource.jsx
+++ b/frontend/src/components/input-output/add-source/AddSource.jsx
@@ -1,3 +1,5 @@
+import { getDefaultFormState } from "@rjsf/utils";
+import validator from "@rjsf/validator-ajv8";
import { Typography } from "antd";
import PropTypes from "prop-types";
import { useEffect, useMemo, useState } from "react";
@@ -121,12 +123,22 @@ function AddSource({
axiosPrivate(requestOptions)
.then((res) => {
const data = res?.data;
- setFormData(metadata || {});
+ const jsonSchema = isLLMWPaidSchema
+ ? transformLlmWhispererJsonSchema(data?.json_schema || {})
+ : data?.json_schema || {};
- if (isLLMWPaidSchema) {
- setSpec(transformLlmWhispererJsonSchema(data?.json_schema || {}));
+ setSpec(jsonSchema);
+
+ if (metadata && Object.keys(metadata).length > 0) {
+ setFormData(metadata);
} else {
- setSpec(data?.json_schema || {});
+ const defaults = getDefaultFormState(
+ validator,
+ jsonSchema,
+ {},
+ jsonSchema,
+ );
+ setFormData(defaults || {});
}
if (data?.oauth) {
@@ -142,7 +154,7 @@ function AddSource({
.finally(() => {
setIsLoading(false);
});
- }, [selectedSourceId]);
+ }, [selectedSourceId, isLLMWPaidSchema]);
useEffect(() => {
if (editItemId?.length && metadata && Object.keys(metadata)?.length) {
diff --git a/unstract/connectors/src/unstract/connectors/filesystems/sharepoint/sharepoint.py b/unstract/connectors/src/unstract/connectors/filesystems/sharepoint/sharepoint.py
index 7491fbf7a..3eacdac30 100644
--- a/unstract/connectors/src/unstract/connectors/filesystems/sharepoint/sharepoint.py
+++ b/unstract/connectors/src/unstract/connectors/filesystems/sharepoint/sharepoint.py
@@ -170,9 +170,11 @@ class SharePointFileSystem(AbstractFileSystem):
if self.client_secret:
if not self.user_email:
error_msg = (
- "OneDrive client credentials require user email. Provide either \n"
- "- user_email (e.g., [email protected]) \n"
- "- OR use OAuth with access_token instead."
+ "No Site URL provided. "
+ "To access a SharePoint site, provide the Site URL "
+ "(e.g., https://contoso.sharepoint.com/sites/mysite). "
+ "To access OneDrive, provide the User Email "
+ "(e.g., [email protected])."
)
raise ConnectorError(
error_msg,
diff --git a/unstract/connectors/src/unstract/connectors/filesystems/sharepoint/static/json_schema.json b/unstract/connectors/src/unstract/connectors/filesystems/sharepoint/static/json_schema.json
index f9555f5da..d83f84c8a 100644
--- a/unstract/connectors/src/unstract/connectors/filesystems/sharepoint/static/json_schema.json
+++ b/unstract/connectors/src/unstract/connectors/filesystems/sharepoint/static/json_schema.json
@@ -10,12 +10,6 @@
"default": "SharePoint / OneDrive Connector",
"description": "A friendly name to identify this connector"
},
- "is_personal": {
- "type": "boolean",
- "title": "Personal Account",
- "default": false,
- "description": "Enable for OneDrive Personal (consumer Microsoft accounts). Leave disabled for SharePoint or OneDrive for Business (work/school accounts)."
- },
"site_url": {
"type": "string",
"title": "Site URL",
@@ -27,7 +21,7 @@
},
"drive_id": {
"type": "string",
- "title": "Drive ID (Optional)",
+ "title": "Drive ID",
"description": "Specific Drive/Document Library ID. Leave empty to use the default drive."
},
"auth_type": {