Skip to content

chore(ibis): add kwargs and security-related arguments for connection info#1205

Merged
douenergy merged 6 commits intoCanner:mainfrom
goldmedal:feat/db-ssl
Jun 4, 2025
Merged

chore(ibis): add kwargs and security-related arguments for connection info#1205
douenergy merged 6 commits intoCanner:mainfrom
goldmedal:feat/db-ssl

Conversation

@goldmedal
Copy link
Copy Markdown
Contributor

@goldmedal goldmedal commented May 27, 2025

Changed

Add the security-related arguments for the following data source:

  • Clikchouse
  • Postgres
  • Snowflake
  • Trino
  • Oracle: dsn

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Added support for specifying additional client-specific options when connecting to ClickHouse, Postgres, Snowflake, and Trino data sources.
    • Enabled Oracle connections using a Data Source Name (DSN) that overrides other connection parameters.
    • Added default connection values for Oracle including host, port, and database.
  • Enhancements

    • Improved flexibility for database connections by allowing extra configuration parameters to be passed to each backend.
  • Tests

    • Added a new test validating Oracle connections using the DSN format.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented May 27, 2025

"""

Walkthrough

This change adds an optional kwargs dictionary field to the connection info classes for ClickHouse, Postgres, Snowflake, and Trino to pass additional keyword arguments to their clients. The Oracle connection info class gains default values for host, port, and database, plus an optional dsn field. Connection methods are updated to use these new fields, including an alternative Oracle connection path using dsn. A new test validates Oracle connection via DSN.

Changes

File(s) Change Summary
ibis-server/app/model/init.py Added optional `kwargs: dict[str, str]
ibis-server/app/model/data_source.py Updated connection methods to unpack and forward kwargs to backend clients; Oracle connection method enhanced to use optional dsn or fallback to host/port/database parameters.
ibis-server/tests/routers/v3/connector/oracle/test_query.py Added async test test_query_with_dsn to verify Oracle connection using DSN string in query endpoint.

Possibly related PRs

Suggested labels

dependencies

Poem

A rabbit hops with joy anew,
Passing kwargs, connections grew!
ClickHouse, Postgres, Snowflake, Trino,
Extra options now on show.
Oracle joins with host and DSN,
Flexible paths to connect again! 🐇✨
"""


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 96c2c26 and 61ae5f9.

📒 Files selected for processing (1)
  • ibis-server/app/model/__init__.py (4 hunks)
🧰 Additional context used
🪛 Pylint (3.3.7)
ibis-server/app/model/__init__.py

[convention] 234-234: Line too long (134/100)

(C0301)


[convention] 212-212: Missing class docstring

(C0115)


[refactor] 212-212: Too few public methods (1/2)

(R0903)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: ci
🔇 Additional comments (2)
ibis-server/app/model/__init__.py (2)

214-225: Verify appropriateness of Oracle connection defaults.

The default values look reasonable for a typical Oracle setup. However, there's a past comment questioning whether the default host should be "localhost".

Please confirm these defaults align with your typical Oracle deployment patterns:

  • host: "localhost"
  • port: "1521"
  • database: "orcl"

232-236: Good implementation of DSN field with proper security handling.

The dsn field implementation correctly uses SecretStr for security and provides clear documentation about its precedence over other connection parameters.

However, consider shortening the description to address the static analysis warning about line length:

-        description="An Oracle Data Source Name. If provided, overrides all other connection arguments except username and password.",
+        description="Oracle Data Source Name. Overrides other connection args except username/password.",
🧰 Tools
🪛 Pylint (3.3.7)

[convention] 234-234: Line too long (134/100)

(C0301)

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added ibis python Pull requests that update Python code labels May 27, 2025
@goldmedal goldmedal changed the title chore(ibis): add kwargs and secure-related parameters for connection info chore(ibis): add kwargs and security-related parameters for connection info May 27, 2025
@goldmedal goldmedal changed the title chore(ibis): add kwargs and security-related parameters for connection info chore(ibis): add kwargs and security-related arguments for connection info May 27, 2025
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🧹 Nitpick comments (3)
ibis-server/app/model/data_source.py (3)

182-182: Improve consistency with other connection methods.

The kwargs handling is correct, but for consistency with other methods, consider using {} instead of dict().

-            **info.kwargs if info.kwargs else dict(),
+            **(info.kwargs if info.kwargs else {}),

203-203: Improve consistency with other connection methods.

Same consistency improvement as suggested for Postgres.

-            **info.kwargs if info.kwargs else dict(),
+            **(info.kwargs if info.kwargs else {}),

215-215: Improve consistency with other connection methods.

Same consistency improvement as suggested for other connection methods.

-            **info.kwargs if info.kwargs else dict(),
+            **(info.kwargs if info.kwargs else {}),
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a41d5c2 and c612acc.

📒 Files selected for processing (2)
  • ibis-server/app/model/__init__.py (4 hunks)
  • ibis-server/app/model/data_source.py (4 hunks)
🧰 Additional context used
🪛 GitHub Actions: ibis CI
ibis-server/app/model/data_source.py

[error] 1-1: Ruff formatting check failed. File would be reformatted. Run 'ruff --fix' to fix code style issues.

@goldmedal goldmedal requested a review from douenergy May 27, 2025 09:10
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (4)
ibis-server/app/model/__init__.py (4)

134-136: Type annotation is too restrictive for kwargs field.

The kwargs field uses dict[str, str] which is too restrictive for database connection parameters that may include integers, booleans, and other types.


206-209: Type annotation is too restrictive for kwargs field.

Same issue as with ClickHouse - the dict[str, str] type annotation should be more flexible to accommodate various parameter types.


258-261: Type annotation is too restrictive for kwargs field.

Same type annotation issue as other database connection classes - should use a more flexible type to accommodate non-string parameter values.


283-286: Type annotation is too restrictive for kwargs field.

Consistent with other connection info classes, this should also use a more flexible type annotation for the kwargs field.

🧹 Nitpick comments (5)
ibis-server/app/model/__init__.py (1)

226-237: Oracle connection fields implementation looks good.

The new Oracle connection fields (sid, service_name, dsn) are well-designed with clear descriptions and proper precedence handling. The implementation correctly uses SecretStr | None for security.

However, consider breaking long description lines to improve readability:

-        description="Unique name of an Oracle Instance, used to construct a DSN if provided.",
+        description=(
+            "Unique name of an Oracle Instance, used to construct a DSN if provided."
+        ),
-        description="Oracle service name, used to construct a DSN if provided. Only one of database and service_name should be provided.",
+        description=(
+            "Oracle service name, used to construct a DSN if provided. "
+            "Only one of database and service_name should be provided."
+        ),
-        description="An Oracle Data Source Name. If provided, overrides all other connection arguments except username and password.",
+        description=(
+            "An Oracle Data Source Name. If provided, overrides all other "
+            "connection arguments except username and password."
+        ),
🧰 Tools
🪛 Pylint (3.3.7)

[convention] 232-232: Line too long (138/100)

(C0301)


[convention] 236-236: Line too long (134/100)

(C0301)

ibis-server/app/model/data_source.py (4)

138-138: Consider using empty dict literal for better readability.

The logic is correct for safely unpacking kwargs, but consider using an empty dict literal for better readability and performance.

-            **info.kwargs if info.kwargs else dict(),
+            **info.kwargs if info.kwargs else {},
🧰 Tools
🪛 Pylint (3.3.7)

[refactor] 138-138: Consider using '{}' instead of a call to 'dict'.

(R1735)


181-181: Consider using empty dict literal for better readability.

Same improvement as with ClickHouse - use empty dict literal instead of dict().

-            **info.kwargs if info.kwargs else dict(),
+            **info.kwargs if info.kwargs else {},
🧰 Tools
🪛 Pylint (3.3.7)

[refactor] 181-181: Consider using '{}' instead of a call to 'dict'.

(R1735)


207-207: Consider using empty dict literal for better readability.

Consistent with other connection methods, use empty dict literal for the fallback.

-            **info.kwargs if info.kwargs else dict(),
+            **info.kwargs if info.kwargs else {},
🧰 Tools
🪛 Pylint (3.3.7)

[refactor] 207-207: Consider using '{}' instead of a call to 'dict'.

(R1735)


219-219: Consider using empty dict literal for better readability.

Same style improvement as other connection methods.

-            **info.kwargs if info.kwargs else dict(),
+            **info.kwargs if info.kwargs else {},
🧰 Tools
🪛 Pylint (3.3.7)

[refactor] 219-219: Consider using '{}' instead of a call to 'dict'.

(R1735)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 164051c and 3595539.

📒 Files selected for processing (2)
  • ibis-server/app/model/__init__.py (5 hunks)
  • ibis-server/app/model/data_source.py (5 hunks)
🧰 Additional context used
🪛 Pylint (3.3.7)
ibis-server/app/model/__init__.py

[convention] 232-232: Line too long (138/100)

(C0301)


[convention] 236-236: Line too long (134/100)

(C0301)

ibis-server/app/model/data_source.py

[refactor] 138-138: Consider using '{}' instead of a call to 'dict'.

(R1735)


[refactor] 181-181: Consider using '{}' instead of a call to 'dict'.

(R1735)


[refactor] 207-207: Consider using '{}' instead of a call to 'dict'.

(R1735)


[refactor] 219-219: Consider using '{}' instead of a call to 'dict'.

(R1735)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: ci
🔇 Additional comments (1)
ibis-server/app/model/data_source.py (1)

192-197: Oracle connection enhancement implemented correctly.

The new Oracle connection parameters (sid, service_name, dsn) are properly extracted and passed to the connection. The implementation correctly handles optional fields by checking for None values before extracting secret values.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (4)
ibis-server/app/model/__init__.py (4)

134-136: Type annotation for kwargs field is too restrictive.

This is consistent with previous feedback - the dict[str, str] type annotation should be dict[str, Any] to accommodate various parameter types like integers for timeouts, booleans for flags, etc.


206-209: Type annotation for kwargs field is too restrictive.

Same issue as other connection info classes - dict[str, str] should be dict[str, Any] for flexibility.


257-260: Type annotation for kwargs field is too restrictive.

Consistent with other connection info classes, this should use dict[str, Any] instead of dict[str, str].


282-285: Type annotation for kwargs field is too restrictive.

Same type annotation issue - should be dict[str, Any] for consistency and flexibility.

🧹 Nitpick comments (6)
ibis-server/app/model/__init__.py (1)

232-236: Consider shortening the field description to address line length.

The description is comprehensive but exceeds the 100-character line limit flagged by static analysis.

Consider splitting the description:

-    dsn: SecretStr | None = Field(
-        default=None,
-        description="An Oracle Data Source Name. If provided, overrides all other connection arguments except username and password.",
-        examples=["localhost:1521/orcl"],
-    )
+    dsn: SecretStr | None = Field(
+        default=None,
+        description="An Oracle Data Source Name. If provided, overrides all other "
+                   "connection arguments except username and password.",
+        examples=["localhost:1521/orcl"],
+    )
🧰 Tools
🪛 Pylint (3.3.7)

[convention] 234-234: Line too long (134/100)

(C0301)

ibis-server/app/model/data_source.py (4)

138-138: Consider using empty dict literal for better performance.

The static analysis tool suggests using {} instead of dict() for better performance and readability.

-            **info.kwargs if info.kwargs else dict(),
+            **info.kwargs if info.kwargs else {},
🧰 Tools
🪛 Pylint (3.3.7)

[refactor] 138-138: Consider using '{}' instead of a call to 'dict'.

(R1735)


181-181: Consider using empty dict literal for better performance.

Same suggestion as for ClickHouse - use {} instead of dict().

-            **info.kwargs if info.kwargs else dict(),
+            **info.kwargs if info.kwargs else {},
🧰 Tools
🪛 Pylint (3.3.7)

[refactor] 181-181: Consider using '{}' instead of a call to 'dict'.

(R1735)


210-210: Consider using empty dict literal for better performance.

Consistent with other connection methods - use {} instead of dict().

-            **info.kwargs if info.kwargs else dict(),
+            **info.kwargs if info.kwargs else {},
🧰 Tools
🪛 Pylint (3.3.7)

[refactor] 210-210: Consider using '{}' instead of a call to 'dict'.

(R1735)


222-222: Consider using empty dict literal for better performance.

Same suggestion as other connection methods - use {} instead of dict().

-            **info.kwargs if info.kwargs else dict(),
+            **info.kwargs if info.kwargs else {},
🧰 Tools
🪛 Pylint (3.3.7)

[refactor] 222-222: Consider using '{}' instead of a call to 'dict'.

(R1735)

ibis-server/tests/routers/v3/connector/oracle/test_query.py (1)

137-160: Well-implemented test for DSN-based Oracle connection.

The test correctly:

  • Constructs DSN from individual connection parameters
  • Uses only required fields (dsn, user, password) as documented
  • Follows the same validation pattern as existing tests
  • Provides coverage for the new DSN functionality

Consider adding a docstring to improve documentation:

+async def test_query_with_dsn(client, manifest_str, connection_info):
+    """Test Oracle connection using DSN format instead of individual parameters."""
-async def test_query_with_dsn(client, manifest_str, connection_info):
🧰 Tools
🪛 Pylint (3.3.7)

[convention] 137-137: Missing function or method docstring

(C0116)


[warning] 137-137: Redefining name 'manifest_str' from outer scope (line 71)

(W0621)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3595539 and 96c2c26.

📒 Files selected for processing (3)
  • ibis-server/app/model/__init__.py (4 hunks)
  • ibis-server/app/model/data_source.py (4 hunks)
  • ibis-server/tests/routers/v3/connector/oracle/test_query.py (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
ibis-server/tests/routers/v3/connector/oracle/test_query.py (3)
ibis-server/tests/conftest.py (1)
  • client (18-23)
ibis-server/tests/routers/v3/connector/oracle/test_function.py (1)
  • manifest_str (31-32)
ibis-server/tests/routers/v3/connector/oracle/conftest.py (1)
  • connection_info (56-65)
🪛 Pylint (3.3.7)
ibis-server/tests/routers/v3/connector/oracle/test_query.py

[convention] 137-137: Missing function or method docstring

(C0116)


[warning] 137-137: Redefining name 'manifest_str' from outer scope (line 71)

(W0621)

ibis-server/app/model/__init__.py

[convention] 234-234: Line too long (134/100)

(C0301)


[convention] 212-212: Missing class docstring

(C0115)


[refactor] 212-212: Too few public methods (1/2)

(R0903)

ibis-server/app/model/data_source.py

[refactor] 138-138: Consider using '{}' instead of a call to 'dict'.

(R1735)


[refactor] 181-181: Consider using '{}' instead of a call to 'dict'.

(R1735)


[convention] 185-185: Missing function or method docstring

(C0116)


[refactor] 210-210: Consider using '{}' instead of a call to 'dict'.

(R1735)


[refactor] 222-222: Consider using '{}' instead of a call to 'dict'.

(R1735)

🔇 Additional comments (2)
ibis-server/app/model/__init__.py (1)

214-225: Oracle connection info enhancements look good.

The addition of default values and the dsn field is well-implemented:

  • Sensible defaults for host ("default"), port ("1521"), and database ("orcl")
  • Clear documentation that DSN overrides other connection arguments except username/password
  • Proper typing with SecretStr | None
ibis-server/app/model/data_source.py (1)

186-200: Oracle DSN implementation is well-designed.

The logic correctly prioritizes DSN when available and falls back to individual connection parameters. The implementation properly:

  • Checks for DSN existence using hasattr and value check
  • Passes through username and password as documented
  • Maintains backward compatibility with existing connection parameters

examples=["localhost"], description="the hostname of your database"
examples=["localhost"],
description="the hostname of your database",
default="default",
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.

I think the default host should be "localhost" ?

@douenergy douenergy merged commit 8b6e8de into Canner:main Jun 4, 2025
5 checks passed
@douenergy
Copy link
Copy Markdown
Contributor

Thanks @goldmedal

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ibis python Pull requests that update Python code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants