Skip to content

feat(integrations): add Google Cloud SQL to @deepnote/database-integrations#398

Closed
sLightlyDev wants to merge 3 commits into
mainfrom
feat/cloud-sql-database-integration
Closed

feat(integrations): add Google Cloud SQL to @deepnote/database-integrations#398
sLightlyDev wants to merge 3 commits into
mainfrom
feat/cloud-sql-database-integration

Conversation

@sLightlyDev

@sLightlyDev sLightlyDev commented Jun 9, 2026

Copy link
Copy Markdown

What / Why

Adds cloud-sql as a supported DatabaseIntegrationType in the @deepnote/database-integrations package.

This is the upstream schema extraction for the Cloud SQL integration — vscode-deepnote#406 added a local shim with the comment "Pending addition to @deepnote/database-integrations; remove once the package includes 'cloud-sql'." This PR fulfils that.

Changes

  • database-integration-types.ts'cloud-sql' added to sqlIntegrationTypes
  • database-integration-metadata-schemas.tscloudSqlMetadataSchema (service_account: z.string(), consistent with Spanner/BigQuery convention)
  • database-integration-config.ts — config union member added
  • secret-field-paths.ts'cloud-sql': ['service_account'] (service account JSON is a secret)
  • database-integration-env-vars.tscase 'cloud-sql': return null (Cloud SQL connects via the cloud-sql-python-connector, not a plain SQLAlchemy URL — satisfies the exhaustiveness check)
  • integrations-prompts/cloud-sql.ts — new CLI prompt (single service_account field, modelled on Spanner)
  • add-integration.ts + edit-integration.ts — import + switch case wired in
  • database-integration-metadata-schemas.test.ts — 2 new test cases

How to review

Start with database-integration-types.ts (one-liner), then database-integration-metadata-schemas.ts, then secret-field-paths.ts, then database-integration-env-vars.ts. The CLI files (add-integration.ts, edit-integration.ts, cloud-sql.ts) follow the exact same pattern as Spanner.

Testing

  • Typecheck: clean (tsc --noEmit across all packages)
  • Unit tests: 227/227 pass in @deepnote/database-integrations; all pass in @deepnote/cli when run in isolation
  • Build: succeeds (ESM + CJS + types)
  • CLI prompt (promptForFieldsCloudSql): not manually run, but covered by typecheck — follows the Spanner pattern exactly
  • Note: some pre-existing add-integration tests are intermittently flaky under parallel local execution (unrelated to this diff); CI is unaffected

Risks

  • Safe: purely additive, no existing behaviour changed
  • The return null in env-vars is intentional — Cloud SQL uses the cloud-sql-python-connector rather than a SQLAlchemy URL (same reason Spanner has its own handler). A full SQLAlchemy/connector implementation would be a follow-up.

Next step

Once this merges and @deepnote/database-integrations publishes a new version, vscode-deepnote#406 can be updated to remove the local shim and consume the package directly.

Summary by CodeRabbit

  • New Features

    • Added Cloud SQL database integration support in the CLI, including prompts to capture Service Account credentials as a secret-backed field for add/edit flows.
  • Behavior Changes

    • Cloud SQL integrations do not produce SQLAlchemy environment payloads (no SQLAlchemy env var generated).
  • Tests

    • Added tests covering Cloud SQL metadata validation, CLI add/edit interactive flows, and env secret handling.

…ations

Registers 'cloud-sql' as a new DatabaseIntegrationType. Adds:
- metadata schema (service_account: string)
- config union member in databaseIntegrationConfigSchema
- secret-field-paths entry (service_account is a secret)
- env-vars case returning null (Cloud SQL uses the cloud-sql-python-connector, not a plain SQLAlchemy URL)
- CLI prompts for add/edit commands
- metadata schema unit tests

Preceded by vscode-deepnote#406 which includes a local shim for E2E verification;
that shim can be removed once this package publishes a new version.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@coderabbitai

coderabbitai Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: bf672418-a912-4cea-ab66-f9ffa487965b

📥 Commits

Reviewing files that changed from the base of the PR and between 5906f60 and ef12dc7.

📒 Files selected for processing (1)
  • packages/cli/src/commands/integrations/tests/edit-integration.cloud-sql.test.ts

📝 Walkthrough

Walkthrough

This PR introduces end-to-end support for the cloud-sql database integration type. It adds cloud-sql to runtime type lists, defines a metadata schema requiring a service account JSON, registers secret field paths, wires a CLI prompt for service_account into add/edit commands, returns null for SQLAlchemy input for cloud-sql, and adds unit and integration tests covering schema and CLI flows.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Updates Docs ⚠️ Warning Cloud SQL documentation file (google-cloud-sql.md) was created but not added to the integrations.md index under Databases section. Add "Google Cloud SQL" to the Databases list in docs/integrations.md to ensure discoverability.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title clearly summarizes the main change: adding Google Cloud SQL support to the database-integrations package.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov

codecov Bot commented Jun 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.95%. Comparing base (d921be7) to head (ef12dc7).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #398      +/-   ##
==========================================
+ Coverage   83.93%   83.95%   +0.02%     
==========================================
  Files         145      146       +1     
  Lines        8018     8029      +11     
  Branches     2165     2230      +65     
==========================================
+ Hits         6730     6741      +11     
  Misses       1287     1287              
  Partials        1        1              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

- env-vars: assert cloud-sql generates no SQLAlchemy var and no errors
- CLI add-integration: cloud-sql happy path (name + service account)
- CLI edit-integration: cloud-sql keep-defaults and update flows

Covers the new lines flagged by codecov/patch on #398.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@packages/cli/src/commands/integrations/tests/add-integration.cloud-sql.test.ts`:
- Line 1: The test file add-integration.cloud-sql.test.ts is misplaced under an
integrations/tests directory; move this .test.ts file to be colocated beside its
source command file (the add-integration.cloud-sql command implementation) so it
follows the repo rule of placing "*.test.ts" next to the source, update any
relative imports inside the test (e.g., the crypto import or local module
imports) so paths resolve after the move, and run the test suite to confirm the
test is discovered and passes.

In
`@packages/cli/src/commands/integrations/tests/edit-integration.cloud-sql.test.ts`:
- Around line 80-114: The test for editIntegration updates the service_account
but never asserts the .env was written; after awaiting promise in the 'updates
the name and service account' test, read envFilePath (the same variable used
earlier) and assert its contents include the updated key
CS_ID_001__SERVICE_ACCOUNT with value new-service-account-data (or the expected
updated secret string) so the test verifies the secret-write to .env; update the
test that calls editIntegration to include this .env read+assert using
EXISTING_YAML/CS_ID_001__SERVICE_ACCOUNT references to locate the correct
integration.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: cb1f0ca2-09a8-4cf2-a322-69cb1f49c0c8

📥 Commits

Reviewing files that changed from the base of the PR and between d921be7 and 5906f60.

📒 Files selected for processing (12)
  • packages/cli/src/commands/integrations/add-integration.ts
  • packages/cli/src/commands/integrations/edit-integration.ts
  • packages/cli/src/commands/integrations/integrations-prompts/cloud-sql.ts
  • packages/cli/src/commands/integrations/tests/add-integration.cloud-sql.test.ts
  • packages/cli/src/commands/integrations/tests/edit-integration.cloud-sql.test.ts
  • packages/database-integrations/src/database-integration-config.ts
  • packages/database-integrations/src/database-integration-env-vars.test.ts
  • packages/database-integrations/src/database-integration-env-vars.ts
  • packages/database-integrations/src/database-integration-metadata-schemas.test.ts
  • packages/database-integrations/src/database-integration-metadata-schemas.ts
  • packages/database-integrations/src/database-integration-types.ts
  • packages/database-integrations/src/secret-field-paths.ts

@sLightlyDev

Copy link
Copy Markdown
Author

Re: test file placement — The tests/ subdirectory is the established convention for this package. Every integration test (alloydb, athena, big-query, clickhouse, databricks, dremio, mariadb, materialize, mindsdb, mongodb, mysql, pgsql, redshift, snowflake, spanner, sql-server, trino) lives under packages/cli/src/commands/integrations/tests/. Moving cloud-sql out of tests/ would break that consistency.

Re: missing .env assertion in the update test — Good catch. Added a readFile + toMatchInlineSnapshot assertion for the .env content after the update (commit ef12dc7). Both tests pass locally.

@sLightlyDev sLightlyDev marked this pull request as ready for review June 9, 2026 13:37
@sLightlyDev sLightlyDev requested a review from a team as a code owner June 9, 2026 13:37
@tkislan

tkislan commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

@coderabbitai approve
since both comments were resolved

@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

@tkislan: Confirmed — both comments resolved. Approving.

✅ Action performed

Comments resolved and changes approved.

@tkislan

tkislan commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

superseded by #403
because of not signed commits

@tkislan tkislan closed this Jun 11, 2026
tkislan added a commit that referenced this pull request Jun 16, 2026
…ations (#403)

* feat(integrations): add Google Cloud SQL to @deepnote/database-integrations

Registers 'cloud-sql' as a new DatabaseIntegrationType. Adds:
- metadata schema (service_account: string)
- config union member in databaseIntegrationConfigSchema
- secret-field-paths entry (service_account is a secret)
- env-vars case returning null (Cloud SQL uses the cloud-sql-python-connector, not a plain SQLAlchemy URL)
- CLI prompts for add/edit commands
- metadata schema unit tests

Preceded by vscode-deepnote#406 which includes a local shim for E2E verification;
that shim can be removed once this package publishes a new version.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* test(integrations): add Cloud SQL test coverage

- env-vars: assert cloud-sql generates no SQLAlchemy var and no errors
- CLI add-integration: cloud-sql happy path (name + service account)
- CLI edit-integration: cloud-sql keep-defaults and update flows

Covers the new lines flagged by codecov/patch on #398.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* test(integrations): assert .env is updated in cloud-sql edit test

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

---------

Co-authored-by: Marko Paleka <[email protected]>
Co-authored-by: Claude Sonnet 4.6 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants