Skip to content

fix: SSL fields missing in some integration metadata schemas - #123

Merged
jankuca merged 2 commits into
mainfrom
jk/ca-cert-text
Nov 5, 2025
Merged

jankuca merged 2 commits into
mainfrom
jk/ca-cert-text

Conversation

@jankuca

@jankuca jankuca commented Nov 5, 2025 •

Copy link
Copy Markdown
Contributor

The caCertificateText field should always accompany the caCertificateName field.

Summary by CodeRabbit

  • New Features

    • Optional CA certificate text and SSL flag added for AlloyDB, MySQL, PostgreSQL, MariaDB and MindsDB integrations; AlloyDB now included in SSL-supported types.
  • Bug Fixes / Behavior Changes

    • CA certificate text is no longer emitted as an environment variable; certificate name is used and tooling references a filesystem certificate path. MongoDB connection strings receive SSL options when enabled.
  • Tests

    • Expanded tests covering CA handling, env var generation, SQLAlchemy input, and MongoDB SSL behavior.
  • Chores

    • Spell-check vocabulary updated to include CA certificate terms.

@coderabbitai

coderabbitai Bot commented Nov 5, 2025 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Schemas for AlloyDB, MariaDB, MindsDB, MySQL, and PostgreSQL now accept optional sslEnabled and caCertificateText alongside caCertificateName. Environment-variable generation excludes caCertificateText (only emits CACERTIFICATE_NAME). SQLAlchemy inputs reference filesystem paths derived from certificate names (sslrootcert / ssl.ca) rather than certificate text. MongoDB SSL injection (adding ssl options to the connection string) is moved into the per-key metadata mapping for connection_string. Tests were added/updated to assert these behaviors.

Sequence Diagram

sequenceDiagram
    participant Client as Metadata Input
    participant Validator as Schema Validation
    participant Mapper as Metadata-Map Processing
    participant EnvGen as Env Var Generation
    participant SQLAlchemy as SQLAlchemy Input
    participant Output as Env Output

    Client->>Validator: submit metadata (sslEnabled?, caCertificateName?, caCertificateText?)
    Validator-->>Mapper: validated metadata

    rect rgb(240,248,255)
      Note over Mapper: Per-integration key mapping
      Mapper->>Mapper: build key/value pairs
      Mapper->>Mapper: if integration==mongodb AND key==connection_string AND sslEnabled==true
      Mapper->>Mapper: transform value via addSslOptionsToMongoConnectionString
    end

    rect rgb(245,245,220)
      Note over EnvGen: Certificate handling
      Mapper->>EnvGen: emit per-integration vars
      EnvGen->>EnvGen: exclude caCertificateText from env vars
      EnvGen->>EnvGen: include CACERTIFICATE_NAME (if present)
      EnvGen->>SQLAlchemy: construct SQLAlchemy input using filesystem path from certificate name (not text)
    end

    EnvGen->>Output: environment variables (no CACERTIFICATE_TEXT)
    SQLAlchemy->>Output: SQLAlchemy config references cert file path
Loading

Pre-merge checks

✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding missing SSL-related fields (caCertificateText and sslEnabled) to integration metadata schemas.

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

@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

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 412679a and 32fc53d.

📒 Files selected for processing (4)
  • packages/database-integrations/src/database-integration-env-vars.test.ts (3 hunks)
  • packages/database-integrations/src/database-integration-env-vars.ts (1 hunks)
  • packages/database-integrations/src/database-integration-metadata-schemas.test.ts (6 hunks)
  • packages/database-integrations/src/database-integration-metadata-schemas.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
packages/*/src/**/*.test.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

packages/*/src/**/*.test.{ts,tsx}: Place test files next to the source files with .test.ts or .test.tsx extension
Use Vitest as the testing framework for all tests
Import { describe, expect, it } from 'vitest' in tests
Use dedent from ts-dedent for multiline string comparisons in tests
Follow existing test patterns (see packages/blocks/src/blocks/*.test.ts); write clear names, group with describe(), cover edge cases, errors, special characters, and verify exact output for code-generation functions

Files:

  • packages/database-integrations/src/database-integration-env-vars.test.ts
  • packages/database-integrations/src/database-integration-metadata-schemas.test.ts
packages/*/src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

packages/*/src/**/*.{ts,tsx}: Use strict type checking and prefer type safety over convenience
Use const for immutable values
Avoid any; use proper type definitions and type guards

Files:

  • packages/database-integrations/src/database-integration-env-vars.test.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-env-vars.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx}: Follow Biome's lint rules as configured in biome.json
Use literal keys (dot notation) instead of bracket notation when possible
Prefer single quotes for strings (except when avoiding escapes)

Files:

  • packages/database-integrations/src/database-integration-env-vars.test.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-env-vars.ts
packages/*/src/**/*

📄 CodeRabbit inference engine (CLAUDE.md)

Place source code under packages/*/src/

Files:

  • packages/database-integrations/src/database-integration-env-vars.test.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-env-vars.ts
🧬 Code graph analysis (2)
packages/database-integrations/src/database-integration-env-vars.test.ts (1)
packages/database-integrations/src/database-integration-env-vars.ts (1)
  • getEnvironmentVariablesForIntegrations (30-90)
packages/database-integrations/src/database-integration-env-vars.ts (1)
packages/database-integrations/src/index.ts (1)
  • EnvVar (4-4)
🪛 GitHub Actions: CI
packages/database-integrations/src/database-integration-env-vars.test.ts

[error] 183-183: CSpell: Unknown word CACERTIFICATETEXT


[error] 187-187: CSpell: Unknown word CACERTIFICATENAME


[error] 1383-1383: CSpell: Unknown word CACERTIFICATETEXT


[error] 1387-1387: CSpell: Unknown word CACERTIFICATENAME


[error] 1765-1765: CSpell: Unknown word CACERTIFICATETEXT


[error] 1769-1769: CSpell: Unknown word CACERTIFICATENAME

🔇 Additional comments (6)
packages/database-integrations/src/database-integration-metadata-schemas.test.ts (1)

764-764: LGTM!

Test updates correctly verify that caCertificateText is accepted by the schemas.

Also applies to: 775-775, 816-816, 827-827, 868-868, 879-879

packages/database-integrations/src/database-integration-env-vars.ts (2)

46-72: LGTM!

Filtering caCertificateText from env vars is correct since only the file path (derived from caCertificateName) is needed. MongoDB SSL injection refactored cleanly into the metadata-map flow.


92-115: LGTM!

MongoDB SSL injection correctly uses caCertificateName to construct the filesystem path, not the certificate text itself.

packages/database-integrations/src/database-integration-env-vars.test.ts (3)

161-196: LGTM!

Test correctly verifies that caCertificateText is excluded from env vars while caCertificateName remains, and that SQLAlchemy uses the filesystem path.


1361-1396: LGTM!

MySQL test mirrors the AlloyDB pattern and correctly validates the exclusion behavior.


1743-1778: LGTM!

PostgreSQL test correctly validates the behavior. CSpell errors for CACERTIFICATETEXT and CACERTIFICATENAME are false positives—these are valid uppercase environment variable names.

@codecov

codecov Bot commented Nov 5, 2025 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.26%. Comparing base (412679a) to head (8abdc03).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #123      +/-   ##
==========================================
+ Coverage   95.24%   95.26%   +0.01%     
==========================================
  Files          25       25              
  Lines         715      718       +3     
  Branches      207      210       +3     
==========================================
+ Hits          681      684       +3     
  Misses         34       34              

☔ View full report in Codecov by Sentry.
📢 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.

coderabbitai[bot]
coderabbitai Bot previously approved these changes Nov 5, 2025
@jankuca jankuca changed the title fix: caCertificateText missing in integration metadata schemas fix: SSL fields missing in some integration metadata schemas Nov 5, 2025

@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

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 53b7102 and 8abdc03.

📒 Files selected for processing (6)
  • cspell.json (1 hunks)
  • packages/database-integrations/src/database-integration-env-vars.test.ts (3 hunks)
  • packages/database-integrations/src/database-integration-env-vars.ts (1 hunks)
  • packages/database-integrations/src/database-integration-metadata-schemas.test.ts (6 hunks)
  • packages/database-integrations/src/database-integration-metadata-schemas.ts (1 hunks)
  • packages/database-integrations/src/database-integration-types.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
packages/*/src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

packages/*/src/**/*.{ts,tsx}: Use strict type checking and prefer type safety over convenience
Use const for immutable values
Avoid any; use proper type definitions and type guards

Files:

  • 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-env-vars.test.ts
  • packages/database-integrations/src/database-integration-types.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx}: Follow Biome's lint rules as configured in biome.json
Use literal keys (dot notation) instead of bracket notation when possible
Prefer single quotes for strings (except when avoiding escapes)

Files:

  • 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-env-vars.test.ts
  • packages/database-integrations/src/database-integration-types.ts
packages/*/src/**/*

📄 CodeRabbit inference engine (CLAUDE.md)

Place source code under packages/*/src/

Files:

  • 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-env-vars.test.ts
  • packages/database-integrations/src/database-integration-types.ts
packages/*/src/**/*.test.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

packages/*/src/**/*.test.{ts,tsx}: Place test files next to the source files with .test.ts or .test.tsx extension
Use Vitest as the testing framework for all tests
Import { describe, expect, it } from 'vitest' in tests
Use dedent from ts-dedent for multiline string comparisons in tests
Follow existing test patterns (see packages/blocks/src/blocks/*.test.ts); write clear names, group with describe(), cover edge cases, errors, special characters, and verify exact output for code-generation functions

Files:

  • packages/database-integrations/src/database-integration-metadata-schemas.test.ts
  • packages/database-integrations/src/database-integration-env-vars.test.ts
🧬 Code graph analysis (2)
packages/database-integrations/src/database-integration-env-vars.ts (1)
packages/database-integrations/src/index.ts (1)
  • EnvVar (4-4)
packages/database-integrations/src/database-integration-env-vars.test.ts (1)
packages/database-integrations/src/database-integration-env-vars.ts (1)
  • getEnvironmentVariablesForIntegrations (30-90)
🔇 Additional comments (8)
cspell.json (1)

43-44: LGTM!

Spell-check vocabulary correctly extended for the new SSL certificate field names.

packages/database-integrations/src/database-integration-metadata-schemas.ts (1)

216-235: LGTM!

SSL fields correctly added to MariaDB, MindsDB, and MySQL schemas. Pattern matches existing implementations (clickhouse, pgsql, alloydb). Optional without cross-validation as clarified in previous review.

Based on learnings

packages/database-integrations/src/database-integration-metadata-schemas.test.ts (3)

756-779: LGTM!

MariaDB tests correctly validate optional SSL fields.


810-833: LGTM!

MindsDB tests correctly validate optional SSL fields.


864-887: LGTM!

MySQL tests correctly validate optional SSL fields.

packages/database-integrations/src/database-integration-types.ts (1)

28-28: LGTM!

AlloyDB correctly added to SSL support list, aligning with its schema.

packages/database-integrations/src/database-integration-env-vars.test.ts (2)

161-196: LGTM!

AlloyDB test correctly verifies caCertificateText exclusion, caCertificateName inclusion, and filesystem path usage in SQLAlchemy.


1361-1396: LGTM!

MySQL test correctly verifies caCertificateText exclusion, caCertificateName inclusion, and filesystem path usage in SQLAlchemy.

@jankuca
jankuca marked this pull request as ready for review November 5, 2025 13:47
@jankuca
jankuca requested a review from a team as a code owner November 5, 2025 13:47
export type DatabaseIntegrationType = (typeof databaseIntegrationTypes)[number]

export const databaseIntegrationTypesWithSslSupport = [
'alloydb',

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.

Adding AlloyDB here because our webapp UI supports configuring SSL for this integration type.

Comment on lines +47 to +50
.filter(([key]) => {
// Filter out caCertificateText - we only provide the path, not the cert text
return key !== 'caCertificateText'
})

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.

  1. We are only using the CA certificate name when constructing the SQL alchemy inputs.
  2. These variables are unnecessarily leaking the certificate contents as env variables. (If anyone thinks that would be desirable, speak up; as far as I know, we do not need this. The certs might also be pretty big.)

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