SmythOS Studio: Open-Source Visual AI Agent Builder and deployable runtime stack from SmythOS. Start with an intuitive drag-and-drop workspace, extend with custom code, and deploy your agents anywhere — local, cloud, or edge — with full governance and control.
JavaScript a2aagentic-aiai-agentsdevtoolsmcp-clientn8n-alternativeno-codeopen-sourceorchestrationsmythosvisual-builder
Enhance namespace validation in DataSource components
Muhammad Hamza Khan908b2cfce177
diff --git a/packages/app/src/backend/routes/api/component/DataSourceIndexer.ts b/packages/app/src/backend/routes/api/component/DataSourceIndexer.tsindex 6299a6f9..f8968ff8 100644--- a/packages/app/src/backend/routes/api/component/DataSourceIndexer.ts+++ b/packages/app/src/backend/routes/api/component/DataSourceIndexer.ts@@ -12,6 +12,10 @@ const getAuthHeaders = (req: any) => {headers['Authorization'] = `Bearer ${req.user.accessToken}`;}+ if (req.headers['x-smyth-team-id']) {+ headers['x-smyth-team-id'] = req.headers['x-smyth-team-id'];+ }+// Add debug header for routing through debugger serverheaders['x-smyth-debug'] = 'true';diff --git a/packages/app/src/builder-ui/components/Component.class/index.ts b/packages/app/src/builder-ui/components/Component.class/index.tsindex 5197ff6d..6597b297 100644--- a/packages/app/src/builder-ui/components/Component.class/index.ts+++ b/packages/app/src/builder-ui/components/Component.class/index.ts@@ -536,7 +536,7 @@ export class Component extends EventEmitter {const hasImportantMessages =messagesContainer &&Array.from(messagesContainer.children).some((msg: Element) => {- return msg.classList.contains('alert') || msg.textContent?.includes('Missing Key');+ return msg.classList.contains('alert') && msg.textContent?.includes('Missing Key');});if (!hasImportantMessages) {diff --git a/packages/app/src/builder-ui/components/DataSourceCleaner.class.ts b/packages/app/src/builder-ui/components/DataSourceCleaner.class.tsindex 3cad4eb1..d0624113 100644--- a/packages/app/src/builder-ui/components/DataSourceCleaner.class.ts+++ b/packages/app/src/builder-ui/components/DataSourceCleaner.class.ts@@ -39,6 +39,7 @@ export class DataSourceCleaner extends Component {}));this.settings.namespaceId.options = this.namespaces;if (this.settingsOpen) this.refreshSettingsSidebar();+ await this.validateNamespaceSelection();}protected async init() {@@ -83,20 +84,41 @@ export class DataSourceCleaner extends Component {protected async checkSettings() {super.checkSettings();- if (!this.namespaces || this.namespaces.length == 0) await delay(3000);+ await this.validateNamespaceSelection();+ }++ /**+ * Validates that the selected namespace exists in the available namespaces list.+ * If the namespace is missing, displays an alert message prompting the user to create one.+ * If the namespace is valid, clears any previously displayed alert messages.+ */+ private async validateNamespaceSelection(): Promise<void> {+ // Wait for namespaces to load if not yet available+ if (!this.namespaces || this.namespaces.length === 0) {+ await delay(3000);+ }- const namespaces = {};- this.namespaces.forEach((ns: any) => {- namespaces[ns.value] = ns.text;+ // Build a lookup map of available namespaces+ const namespacesMap: Record<string, string> = {};+ this.namespaces.forEach((ns) => {+ namespacesMap[ns.value] = ns.text;});- if (this.data['namespaceId']) {- const nsId = this.data['namespaceId'];- if (!namespaces[nsId]) {++ // Validate the selected namespace+ const nsId = this.data['namespaceId'] as string | undefined;+ if (nsId) {+ const messageCssClass = nsId.replace(/ /g, '-');++ if (!namespacesMap[nsId]) {console.log('Namespace Missing', nsId);this.addComponentMessage(`Missing Data Space<br /><a href="/data" target="_blank" style="color:#33b;text-decoration:underline">Create one</a> then configure it for this component`,'alert',+ null,+ messageCssClass,);+ } else {+ this.clearComponentMessage(`.messages-container .${messageCssClass}`);}}}diff --git a/packages/app/src/builder-ui/components/DataSourceIndexer.class.ts b/packages/app/src/builder-ui/components/DataSourceIndexer.class.tsindex 17e4316a..b1578855 100644--- a/packages/app/src/builder-ui/components/DataSourceIndexer.class.ts+++ b/packages/app/src/builder-ui/components/DataSourceIndexer.class.ts@@ -41,6 +41,7 @@ export class DataSourceIndexer extends Component {}));this.settings.namespace.options = this.namespaces;if (this.settingsOpen) this.refreshSettingsSidebar();+ await this.validateNamespaceSelection();}protected async init() {@@ -125,20 +126,41 @@ export class DataSourceIndexer extends Component {protected async checkSettings() {super.checkSettings();- if (!this.namespaces || this.namespaces.length == 0) await delay(3000);+ await this.validateNamespaceSelection();+ }++ /**+ * Validates that the selected namespace exists in the available namespaces list.+ * If the namespace is missing, displays an alert message prompting the user to create one.+ * If the namespace is valid, clears any previously displayed alert messages.+ */+ private async validateNamespaceSelection(): Promise<void> {+ // Wait for namespaces to load if not yet available+ if (!this.namespaces || this.namespaces.length === 0) {+ await delay(3000);+ }- const namespaces = {};- this.namespaces.forEach((ns: any) => {- namespaces[ns.value] = ns.text;+ // Build a lookup map of available namespaces+ const namespacesMap: Record<string, string> = {};+ this.namespaces.forEach((ns) => {+ namespacesMap[ns.value] = ns.text;});- if (this.data['namespace']) {- const nsId = this.data['namespace'];- if (!namespaces[nsId]) {++ // Validate the selected namespace+ const nsId = this.data['namespace'] as string | undefined;+ if (nsId) {+ const messageCssClass = nsId.replace(/ /g, '-');++ if (!namespacesMap[nsId]) {console.log('Namespace Missing', nsId);this.addComponentMessage(`Missing Data Space<br /><a href="/data" target="_blank" style="color:#33b;text-decoration:underline">Create one</a> then configure it for this component`,'alert',+ null,+ messageCssClass,);+ } else {+ this.clearComponentMessage(`.messages-container .${messageCssClass}`);}}}diff --git a/packages/app/src/builder-ui/components/DataSourceLookup.class.ts b/packages/app/src/builder-ui/components/DataSourceLookup.class.tsindex 8ea0ff9b..6b084a01 100644--- a/packages/app/src/builder-ui/components/DataSourceLookup.class.ts+++ b/packages/app/src/builder-ui/components/DataSourceLookup.class.ts@@ -40,6 +40,7 @@ export class DataSourceLookup extends Component {}));this.settings.namespace.options = this.namespaces;if (this.settingsOpen) this.refreshSettingsSidebar();+ await this.validateNamespaceSelection();}protected async init() {@@ -122,20 +123,41 @@ export class DataSourceLookup extends Component {protected async checkSettings() {super.checkSettings();- if (!this.namespaces || this.namespaces.length == 0) await delay(3000);+ await this.validateNamespaceSelection();+ }++ /**+ * Validates that the selected namespace exists in the available namespaces list.+ * If the namespace is missing, displays an alert message prompting the user to create one.+ * If the namespace is valid, clears any previously displayed alert messages.+ */+ private async validateNamespaceSelection(): Promise<void> {+ // Wait for namespaces to load if not yet available+ if (!this.namespaces || this.namespaces.length === 0) {+ await delay(3000);+ }- const namespaces = {};- this.namespaces.forEach((ns: any) => {- namespaces[ns.value] = ns.text;+ // Build a lookup map of available namespaces+ const namespacesMap: Record<string, string> = {};+ this.namespaces.forEach((ns) => {+ namespacesMap[ns.value] = ns.text;});- if (this.data['namespace']) {- const nsId = this.data['namespace'];- if (!namespaces[nsId]) {++ // Validate the selected namespace+ const nsId = this.data['namespace'] as string | undefined;+ if (nsId) {+ const messageCssClass = nsId.replace(/ /g, '-');++ if (!namespacesMap[nsId]) {console.log('Namespace Missing', nsId);this.addComponentMessage(`Missing Data Space<br /><a href="/data" target="_blank" style="color:#33b;text-decoration:underline">Create one</a> then configure it for this component`,'alert',+ null,+ messageCssClass,);+ } else {+ this.clearComponentMessage(`.messages-container .${messageCssClass}`);}}}