diff --git a/src/aiProviders/continue/continueContextProvider.ts b/src/aiProviders/continue/continueContextProvider.ts index e01b1793..6f08f8a5 100644 --- a/src/aiProviders/continue/continueContextProvider.ts +++ b/src/aiProviders/continue/continueContextProvider.ts @@ -146,18 +146,20 @@ export class db2ContextProvider implements IContextProvider { ); for (const table of Object.keys(tableRefs)) { const columnData: TableColumn[] = tableRefs[table]; - const tableSchema = - columnData.length > 0 ? columnData[0].TABLE_SCHEMA : null; - - // create context item - let prompt = `Db2 for i Table meta data for schema ${tableSchema} table ${table}\n`; - prompt += `Column Info: ${JSON.stringify(columnData)}\n\n`; - - contextItems.push({ - name: `${job.name}-${tableSchema}-${table}`, - description: `Schema and table information for ${table}`, - content: prompt, - }); + if (columnData && columnData.length > 0) { + const tableSchema = + columnData.length > 0 ? columnData[0].TABLE_SCHEMA : null; + + // create context item + let prompt = `Db2 for i Table meta data for schema ${tableSchema} table ${table}\n`; + prompt += `Column Info: ${JSON.stringify(columnData)}\n\n`; + + contextItems.push({ + name: `${job.name}-${tableSchema}-${table}`, + description: `Schema and table information for ${table}`, + content: prompt, + }); + } } return contextItems; @@ -195,6 +197,5 @@ export async function registerContinueProvider() { const continueAPI = continueEx?.exports; continueAPI?.registerCustomContextProvider(provider); vscode.commands.executeCommand('setContext', 'vscode-db2i:continueExtensionActive', true); - vscode.window.showInformationMessage(`@Db2i context provider enabled in Continue!`); } }