Skip to content
Merged
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
2 changes: 1 addition & 1 deletion wren-engine
Submodule wren-engine updated 907 files
7 changes: 7 additions & 0 deletions wren-ui/public/images/dataSource/oracle.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions wren-ui/src/apollo/client/graphql/__types__.ts
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ export enum DataSourceName {
CLICK_HOUSE = 'CLICK_HOUSE',
DUCKDB = 'DUCKDB',
MSSQL = 'MSSQL',
ORACLE = 'ORACLE',
MYSQL = 'MYSQL',
POSTGRES = 'POSTGRES',
SNOWFLAKE = 'SNOWFLAKE',
Expand Down
2 changes: 2 additions & 0 deletions wren-ui/src/apollo/server/adaptors/ibisAdaptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export enum SupportedDataSource {
BIG_QUERY = 'BIG_QUERY',
SNOWFLAKE = 'SNOWFLAKE',
MYSQL = 'MYSQL',
ORACLE = 'ORACLE',
MSSQL = 'MSSQL',
CLICK_HOUSE = 'CLICK_HOUSE',
TRINO = 'TRINO',
Expand All @@ -89,6 +90,7 @@ const dataSourceUrlMap: Record<SupportedDataSource, string> = {
[SupportedDataSource.BIG_QUERY]: 'bigquery',
[SupportedDataSource.SNOWFLAKE]: 'snowflake',
[SupportedDataSource.MYSQL]: 'mysql',
[SupportedDataSource.ORACLE]: 'oracle',
[SupportedDataSource.MSSQL]: 'mssql',
[SupportedDataSource.CLICK_HOUSE]: 'clickhouse',
[SupportedDataSource.TRINO]: 'trino',
Expand Down
18 changes: 18 additions & 0 deletions wren-ui/src/apollo/server/dataSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
CLICK_HOUSE_CONNECTION_INFO,
TRINO_CONNECTION_INFO,
SNOWFLAKE_CONNECTION_INFO,
ORACLE_CONNECTION_INFO,
} from './repositories';
import { DataSourceName } from './types';
import { getConfig } from './config';
Expand Down Expand Up @@ -131,6 +132,23 @@ const dataSource = {
HostBasedConnectionInfo
>,

// Oracle
[DataSourceName.ORACLE]: {
sensitiveProps: ['password'],
toIbisConnectionInfo(connectionInfo) {
const decryptedConnectionInfo = decryptConnectionInfo(
DataSourceName.ORACLE,
connectionInfo,
);
const { host, port, database, user, password } =
decryptedConnectionInfo as ORACLE_CONNECTION_INFO;
return { host, port, database, user, password };
},
} as IDataSourceConnectionInfo<
ORACLE_CONNECTION_INFO,
HostBasedConnectionInfo
>,
Comment on lines +135 to +150
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot Apr 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Oracle implementation missing SSL handling

The implementation doesn't account for the SSL option that exists in the OracleProperties UI component. This will cause the SSL setting to be ignored when connecting to Oracle databases.

Reference the ClickHouse implementation (lines 180-199) on how to handle SSL parameters:

// Oracle
[DataSourceName.ORACLE]: {
  sensitiveProps: ['password'],
  toIbisConnectionInfo(connectionInfo) {
    const decryptedConnectionInfo = decryptConnectionInfo(
      DataSourceName.ORACLE,
      connectionInfo,
    );
-    const { host, port, database, user, password } =
+    const { host, port, database, user, password, ssl } =
      decryptedConnectionInfo as ORACLE_CONNECTION_INFO;
-    return { host, port, database, user, password };
+    return { 
+      host, 
+      port, 
+      database, 
+      user, 
+      password,
+      ...(ssl && { kwargs: { ssl: true } })
+    };
  },
} as IDataSourceConnectionInfo<
  ORACLE_CONNECTION_INFO,
  HostBasedConnectionInfo
>,
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// Oracle
[DataSourceName.ORACLE]: {
sensitiveProps: ['password'],
toIbisConnectionInfo(connectionInfo) {
const decryptedConnectionInfo = decryptConnectionInfo(
DataSourceName.ORACLE,
connectionInfo,
);
const { host, port, database, user, password } =
decryptedConnectionInfo as ORACLE_CONNECTION_INFO;
return { host, port, database, user, password };
},
} as IDataSourceConnectionInfo<
ORACLE_CONNECTION_INFO,
HostBasedConnectionInfo
>,
// Oracle
[DataSourceName.ORACLE]: {
sensitiveProps: ['password'],
toIbisConnectionInfo(connectionInfo) {
const decryptedConnectionInfo = decryptConnectionInfo(
DataSourceName.ORACLE,
connectionInfo,
);
const { host, port, database, user, password, ssl } =
decryptedConnectionInfo as ORACLE_CONNECTION_INFO;
return {
host,
port,
database,
user,
password,
...(ssl && { kwargs: { ssl: true } }),
};
},
} as IDataSourceConnectionInfo<
ORACLE_CONNECTION_INFO,
HostBasedConnectionInfo
>,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the first comment alone. I'm not sure if ...(ssl && { kwargs: { ssl: true } }) would be necessary

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧩 Analysis chain

@narsik123 I reviewed the code and can see that your OracleProperties component includes an SSL toggle switch:

<Form.Item
  label={t('ssl')}
  name="ssl"
  valuePropName="checked"
  tooltip={t('dataSource.sslTooltip')}
>
  <Switch />
</Form.Item>

Since you've added this SSL option in the UI, you should handle it in the implementation to ensure the user's selection is respected when connecting to Oracle databases.

The suggested approach using ...(ssl && { kwargs: { ssl: true } }) follows the same pattern used by MS SQL Server in your codebase:

...(trustServerCertificate && { kwargs: { trustServerCertificate: 'YES' } })

This is the standard pattern in your codebase for passing optional connection parameters via the kwargs property when using host-based connections. Without this implementation, the SSL toggle in your UI won't have any effect on the actual connection.

I recommend including the SSL handling as suggested to maintain consistency with how other database types handle connection parameters.


🏁 Script executed:

#!/bin/bash
# Check if OracleProperties has SSL functionality
echo "=== OracleProperties SSL Check ==="
grep -A 5 -B 5 "ssl" wren-ui/src/components/pages/setup/dataSources/OracleProperties.tsx

# Check ORACLE_CONNECTION_INFO interface
echo -e "\n\n=== ORACLE_CONNECTION_INFO Interface Definition ==="
grep -A 10 "ORACLE_CONNECTION_INFO" wren-ui/src/apollo/server/repositories/projectRepository.ts

# Check how MS SQL (similar host-based connection) handles additional parameters
echo -e "\n\n=== MS SQL Implementation ==="
grep -A 15 -B 5 "\[DataSourceName.MSSQL\]" wren-ui/src/apollo/server/dataSource.ts

Length of output: 1917


🏁 Script executed:

#!/bin/bash
# Let's see the full OracleProperties component to understand the SSL implementation
cat wren-ui/src/components/pages/setup/dataSources/OracleProperties.tsx

Length of output: 2329


@narsik123 I've found an important inconsistency that needs addressing:

  1. Your OracleProperties component has an SSL toggle:

    <Form.Item label="Use SSL" name="ssl" valuePropName="checked">
      <Switch />
    </Form.Item>
  2. But the ORACLE_CONNECTION_INFO interface doesn't include an ssl property:

    export interface ORACLE_CONNECTION_INFO {
      host: string;
      port: number;
      user: string;
      password: string;
      database: string;
    }

This means even if users toggle SSL in the UI, that setting won't be captured in the connection info. You need to:

  1. First add the ssl: boolean; property to the ORACLE_CONNECTION_INFO interface
  2. Then implement SSL handling in the connection logic

The suggested pattern ...(ssl && { kwargs: { ssl: true } }) follows how MS SQL handles its trustServerCertificate option and would be appropriate once the interface includes the ssl property.

Without these changes, the SSL toggle in your UI won't actually do anything.


🧬 Code Graph Analysis Results

Relevant snippets from wren-ui/src/apollo/server/repositories/projectRepository.ts (lines 13-82)

These define the TypeScript interfaces for connection info objects used in the main file, including the ssl property for Postgres and ClickHouse, and trustServerCertificate for MS SQL:

export interface BIG_QUERY_CONNECTION_INFO {
  projectId: string;
  datasetId: string;
  credentials: string;
}

export interface POSTGRES_CONNECTION_INFO {
  host: string;
  port: number;
  user: string;
  password: string;
  database: string;
  ssl: boolean;
}

export interface MYSQL_CONNECTION_INFO {
  host: string;
  port: number;
  user: string;
  password: string;
  database: string;
}

export interface ORACLE_CONNECTION_INFO {
  host: string;
  port: number;
  user: string;
  password: string;
  database: string;
}

export interface MS_SQL_CONNECTION_INFO {
  host: string;
  port: number;
  user: string;
  password: string;
  database: string;
  trustServerCertificate: boolean;
}

export interface CLICK_HOUSE_CONNECTION_INFO {
  host: string;
  port: number;
  user: string;
  password: string;
  database: string;
  ssl: boolean;
}

export interface TRINO_CONNECTION_INFO {
  host: string;
  port: number;
  schemas: string;
  username: string;
  password: string;
  ssl: boolean;
}

export interface SNOWFLAKE_CONNECTION_INFO {
  user: string;
  password: string;
  account: string;
  database: string;
  schema: string;
}

export interface DUCKDB_CONNECTION_INFO {
  initSql: string;
  extensions: Array<string>;
  configurations: Record<string, any>;
}

export type WREN_AI_CONNECTION_INFO =
  | BIG_QUERY_CONNECTION_INFO
  | POSTGRES_CONNECTION_INFO
  | MYSQL_CONNECTION_INFO
  | ORACLE_CONNECTION_INFO
  | DUCKDB_CONNECTION_INFO
  | MS_SQL_CONNECTION_INFO
  | CLICK_HOUSE_CONNECTION_INFO
  | TRINO_CONNECTION_INFO
  | SNOWFLAKE_CONNECTION_INFO;

Relevant snippets from wren-ui/src/apollo/server/adaptors/ibisAdaptor.ts (lines 30-67)

These define the Ibis connection info interfaces returned by the toIbisConnectionInfo functions, showing the expected structure for Postgres, Trino, Snowflake, BigQuery, etc.:

export interface HostBasedConnectionInfo {
  host: string;
  port: number;
  database: string;
  user: string;
  password: string;
}

export interface UrlBasedConnectionInfo {
  connectionUrl: string;
}

export interface IbisBigQueryConnectionInfo {
  project_id: string;
  dataset_id: string;
  credentials: string; // base64 encoded
}

export type IbisPostgresConnectionInfo =
  | UrlBasedConnectionInfo
  | HostBasedConnectionInfo;

export interface IbisTrinoConnectionInfo {
  host: string;
  port: number;
  catalog: string;
  schema: string;
  user: string;
  password: string;
}

export interface IbisSnowflakeConnectionInfo {
  user: string;
  password: string;
  account: string;
  database: string;
  schema: string;
}

Summary of wren-ui/src/apollo/server/dataSource.ts

  • The file defines a dataSource object keyed by DataSourceName enum values.
  • Each data source entry specifies sensitiveProps (e.g., password, credentials) and a toIbisConnectionInfo method that converts the decrypted connection info into the expected Ibis connection info format.
  • For Postgres, the toIbisConnectionInfo method:
    • Decrypts the connection info.
    • Extracts host, port, database, user, password, and ssl.
    • URL-encodes the password.
    • Constructs a connection URL string including sslmode=require if ssl is true.
  • For MS SQL, a similar pattern is used, with an optional kwargs property added if trustServerCertificate is true.
  • For ClickHouse, the connection URL includes secure=1 if ssl is true.
  • For Trino, the host URL is prefixed with https:// if ssl is true, otherwise http://.
  • The user comment references uncertainty about the necessity of (ssl && { kwargs: { ssl: true } }) pattern, which is similar to the existing pattern used for MS SQL with trustServerCertificate.

Possibly relevant snippet from migration wren-ui/migrations/20240530062809_transfer_project_table_data.js (lines 40-41)

const ssl =
        project.configurations && project.configurations.ssl ? true : false;

This snippet shows how the ssl flag might be set from project configurations, relevant to understanding how ssl is used in connection info.


Possibly relevant snippet from wren-ui/src/apollo/server/config.ts (lines 153-155)

export function getConfig(): IConfig {
  return { ...defaultConfig, ...pickBy(config) };
}

This shows the getConfig function used in dataSource.ts to obtain configuration, which is then used to initialize the Encryptor.


Possibly relevant snippet from wren-ui/src/pages/api/graphql.ts (lines 24-28)

export const config: PageConfig = {
  api: {
    bodyParser: false,
  },
};

This snippet is unrelated to connection info or SSL handling but is included for completeness.


[End of relevant snippets]


✏️ Learnings added
Learnt from: narsik123
PR: Canner/WrenAI#1606
File: wren-ui/src/apollo/server/dataSource.ts:135-150
Timestamp: 2025-04-28T20:09:06.069Z
Learning: The Oracle data source in WrenAI includes an SSL toggle in the UI (OracleProperties component) and should pass this setting to the connection info using the pattern `...(ssl && { kwargs: { ssl: true } })` for consistency with other host-based connections like MS SQL.

Learnt from: narsik123
PR: Canner/WrenAI#1606
File: wren-ui/src/apollo/server/dataSource.ts:135-150
Timestamp: 2025-04-28T20:09:06.069Z
Learning: The Oracle data source implementation has an inconsistency: the OracleProperties UI component includes an SSL toggle switch, but the ORACLE_CONNECTION_INFO interface doesn't include an ssl property. This means the SSL setting in the UI has no effect on the actual connection. The interface should be updated to include ssl:boolean, and the implementation should use the pattern `...(ssl && { kwargs: { ssl: true } })` for handling SSL.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.


// SQL Server
[DataSourceName.MSSQL]: {
sensitiveProps: ['password'],
Expand Down
2 changes: 2 additions & 0 deletions wren-ui/src/apollo/server/mdl/mdlBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,8 @@ export class MDLBuilder implements IMDLBuilder {
return WrenEngineDataSourceType.POSTGRES;
case DataSourceName.MYSQL:
return WrenEngineDataSourceType.MYSQL;
case DataSourceName.ORACLE:
return WrenEngineDataSourceType.ORACLE;
case DataSourceName.MSSQL:
return WrenEngineDataSourceType.MSSQL;
case DataSourceName.CLICK_HOUSE:
Expand Down
1 change: 1 addition & 0 deletions wren-ui/src/apollo/server/mdl/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ export enum WrenEngineDataSourceType {
CANNER = 'CANNER',
CLICKHOUSE = 'CLICKHOUSE',
MSSQL = 'MSSQL',
ORACLE = 'ORACLE',
MYSQL = 'MYSQL',
POSTGRES = 'POSTGRES',
SNOWFLAKE = 'SNOWFLAKE',
Expand Down
9 changes: 9 additions & 0 deletions wren-ui/src/apollo/server/repositories/projectRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ export interface MYSQL_CONNECTION_INFO {
database: string;
}

export interface ORACLE_CONNECTION_INFO {
host: string;
port: number;
user: string;
password: string;
database: string;
}

export interface MS_SQL_CONNECTION_INFO {
host: string;
port: number;
Expand Down Expand Up @@ -77,6 +85,7 @@ export type WREN_AI_CONNECTION_INFO =
| BIG_QUERY_CONNECTION_INFO
| POSTGRES_CONNECTION_INFO
| MYSQL_CONNECTION_INFO
| ORACLE_CONNECTION_INFO
| DUCKDB_CONNECTION_INFO
| MS_SQL_CONNECTION_INFO
| CLICK_HOUSE_CONNECTION_INFO
Expand Down
1 change: 1 addition & 0 deletions wren-ui/src/apollo/server/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export const typeDefs = gql`
DUCKDB
POSTGRES
MYSQL
ORACLE
MSSQL
CLICK_HOUSE
TRINO
Expand Down
1 change: 1 addition & 0 deletions wren-ui/src/apollo/server/types/dataSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export enum DataSourceName {
DUCKDB = 'DUCKDB',
POSTGRES = 'POSTGRES',
MYSQL = 'MYSQL',
ORACLE = 'ORACLE',
MSSQL = 'MSSQL',
CLICK_HOUSE = 'CLICK_HOUSE',
TRINO = 'TRINO',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
import { Form, Input, Switch } from 'antd';
import { ERROR_TEXTS } from '@/utils/error';
import { FORM_MODE } from '@/utils/enum';
import { hostValidator } from '@/utils/validator';

interface Props {
mode?: FORM_MODE;
}

export default function OracleProperties(props: Props) {
const { mode } = props;
const isEditMode = mode === FORM_MODE.EDIT;
return (
<>
<Form.Item
label="Display name"
name="displayName"
required
rules={[
{
required: true,
message: ERROR_TEXTS.CONNECTION.DISPLAY_NAME.REQUIRED,
},
]}
>
<Input />
</Form.Item>
<Form.Item
label="Host"
name="host"
required
rules={[
{
required: true,
validator: hostValidator,
},
]}
>
<Input placeholder="10.1.1.1" disabled={isEditMode} />
</Form.Item>
<Form.Item
label="Port"
name="port"
required
rules={[
{
required: true,
message: ERROR_TEXTS.CONNECTION.PORT.REQUIRED,
},
]}
>
<Input placeholder="1521" disabled={isEditMode} />
</Form.Item>
<Form.Item
label="Username"
name="user"
rules={[
{
required: true,
message: ERROR_TEXTS.CONNECTION.USERNAME.REQUIRED,
},
]}
>
<Input />
</Form.Item>
<Form.Item
label="Password"
name="password"
required
rules={[
{
required: true,
message: ERROR_TEXTS.CONNECTION.PASSWORD.REQUIRED,
},
]}
>
<Input.Password placeholder="input password" />
</Form.Item>
<Form.Item
label="Database name"
name="database"
required
rules={[
{
required: true,
message: ERROR_TEXTS.CONNECTION.DATABASE.REQUIRED,
},
]}
>
<Input placeholder="Oracle database name" disabled={isEditMode} />
</Form.Item>
</>
);
}
5 changes: 5 additions & 0 deletions wren-ui/src/components/pages/setup/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ export const DATA_SOURCE_OPTIONS = {
guide: 'https://docs.getwren.ai/oss/guide/connect/mysql',
disabled: false,
},
[DATA_SOURCES.ORACLE]: {
...getDataSourceConfig(DATA_SOURCES.ORACLE),
guide: 'https://docs.getwren.ai/oss/guide/connect/oracle',
disabled: false,
},
[DATA_SOURCES.MSSQL]: {
...getDataSourceConfig(DATA_SOURCES.MSSQL),
guide: 'https://docs.getwren.ai/oss/guide/connect/sqlserver',
Expand Down
7 changes: 7 additions & 0 deletions wren-ui/src/utils/dataSourceType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { DATA_SOURCES } from '@/utils/enum';
import BigQueryProperties from '@/components/pages/setup/dataSources/BigQueryProperties';
import DuckDBProperties from '@/components/pages/setup/dataSources/DuckDBProperties';
import MySQLProperties from '@/components/pages/setup/dataSources/MySQLProperties';
import OracleProperties from '@/components/pages/setup/dataSources/OracleProperties';
import PostgreSQLProperties from '@/components/pages/setup/dataSources/PostgreSQLProperties';
import SQLServerProperties from '@/components/pages/setup/dataSources/SQLServerProperties';
import ClickHouseProperties from '@/components/pages/setup/dataSources/ClickHouseProperties';
Expand All @@ -16,6 +17,8 @@ export const getDataSourceImage = (dataSource: DATA_SOURCES | string) => {
return '/images/dataSource/postgreSql.svg';
case DATA_SOURCES.MYSQL:
return '/images/dataSource/mysql.svg';
case DATA_SOURCES.ORACLE:
return '/images/dataSource/oracle.svg';
case DATA_SOURCES.MSSQL:
return '/images/dataSource/sqlserver.svg';
case DATA_SOURCES.CLICK_HOUSE:
Expand All @@ -39,6 +42,8 @@ export const getDataSourceName = (dataSource: DATA_SOURCES | string) => {
return 'PostgreSQL';
case DATA_SOURCES.MYSQL:
return 'MySQL';
case DATA_SOURCES.ORACLE:
return 'Oracle';
case DATA_SOURCES.MSSQL:
return 'SQL Server';
case DATA_SOURCES.CLICK_HOUSE:
Expand All @@ -62,6 +67,8 @@ export const getDataSourceProperties = (dataSource: DATA_SOURCES | string) => {
return PostgreSQLProperties;
case DATA_SOURCES.MYSQL:
return MySQLProperties;
case DATA_SOURCES.ORACLE:
return OracleProperties;
case DATA_SOURCES.MSSQL:
return SQLServerProperties;
case DATA_SOURCES.CLICK_HOUSE:
Expand Down
1 change: 1 addition & 0 deletions wren-ui/src/utils/enum/dataSources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export enum DATA_SOURCES {
DUCKDB = 'DUCKDB',
POSTGRES = 'POSTGRES',
MYSQL = 'MYSQL',
ORACLE = 'ORACLE',
MSSQL = 'MSSQL',
CLICK_HOUSE = 'CLICK_HOUSE',
TRINO = 'TRINO',
Expand Down