Skip to content

fix(sql-alchemy-input): check if auth method is federated - #144

Merged
saltenasl merged 1 commit into
mainfrom
ls/fix-fed-auth-bug
Nov 12, 2025
Merged

saltenasl merged 1 commit into
mainfrom
ls/fix-fed-auth-bug

Conversation

@saltenasl

@saltenasl saltenasl commented Nov 12, 2025 •

Copy link
Copy Markdown
Contributor

getSqlAlchemyInput would return null in case snowflake was using an auth method of type password.

Summary by CodeRabbit

  • Bug Fixes

    • Refined validation logic for federated authentication methods across database integrations, ensuring proper handling of recognized and unrecognized authentication types.
  • Tests

    • Added comprehensive test coverage for federated authentication scenarios with BigQuery, Redshift, and Snowflake integrations, including various authentication configurations and SSH options.

@saltenasl
saltenasl requested a review from a team as a code owner November 12, 2025 13:22
@coderabbitai

coderabbitai Bot commented Nov 12, 2025 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

This PR refines the federated authentication handling in SQLAlchemy env var generation. The main logic change tightens the early-return condition in getSqlAlchemyInput to only return null when integration.federated_auth_method is non-null and recognized by isFederatedAuthMethod. Previously, any truthy value triggered an early exit. New tests verify correct URL and parameter propagation across BigQuery, Redshift, and Snowflake with various federated auth methods.

Sequence Diagram

sequenceDiagram
    participant Caller
    participant getSqlAlchemyInput
    participant isFederatedAuthMethod
    participant switch logic

    Caller->>getSqlAlchemyInput: call with integration
    
    alt federated_auth_method is null
        getSqlAlchemyInput->>switch logic: proceed
    else federated_auth_method is truthy
        getSqlAlchemyInput->>isFederatedAuthMethod: check if recognized
        alt recognized method
            isFederatedAuthMethod-->>getSqlAlchemyInput: true
            getSqlAlchemyInput-->>Caller: return null
        else unrecognized method
            isFederatedAuthMethod-->>getSqlAlchemyInput: false
            getSqlAlchemyInput->>switch logic: proceed to integration.type switch
            switch logic-->>Caller: return generated env vars
        end
    end
Loading

Possibly related PRs

Suggested reviewers

  • Artmann

Pre-merge checks

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main fix: refining the federated auth method check in getSqlAlchemyInput to validate methods properly.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

📜 Recent 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 764ee1e and 9295cb5.

📒 Files selected for processing (2)
  • packages/database-integrations/src/database-integration-env-vars.test.ts (3 hunks)
  • packages/database-integrations/src/database-integration-env-vars.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-env-vars.test.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-env-vars.test.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-env-vars.test.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-env-vars.test.ts
🧬 Code graph analysis (2)
packages/database-integrations/src/database-integration-env-vars.ts (1)
packages/database-integrations/src/sql-integration-auth-methods.ts (1)
  • isFederatedAuthMethod (44-46)
packages/database-integrations/src/database-integration-env-vars.test.ts (1)
packages/database-integrations/src/database-integration-env-vars.ts (1)
  • getEnvironmentVariablesForIntegrations (17-77)
🔇 Additional comments (4)
packages/database-integrations/src/database-integration-env-vars.test.ts (3)

388-437: Test correctly verifies non-federated 'service-account' value.

Validates that federated_auth_method: 'service-account' doesn't trigger the early return guard, allowing normal BigQuery SQL Alchemy generation.


1906-1936: Test correctly verifies non-federated 'username-and-password' value.

Ensures Redshift password authentication continues to generate SQL Alchemy input when federated_auth_method is set to a non-federated value.


2274-2302: Test directly addresses the reported bug.

Verifies Snowflake password authentication generates SQL Alchemy input even when federated_auth_method: 'password' is set, fixing the issue described in the PR.

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

139-141: Fix verified—correct type guard prevents non-federated values from blocking SQLAlchemy generation.

The isFederatedAuthMethod type guard properly validates against the actual federated methods list (Okta, NativeSnowflake, AzureAd, KeyPair, GoogleOauth, IndividualCredentials). The double condition—null check plus type guard—ensures only recognized federated methods trigger the early return.


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

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

@codecov

codecov Bot commented Nov 12, 2025 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.41%. Comparing base (764ee1e) to head (9295cb5).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #144   +/-   ##
=======================================
  Coverage   95.41%   95.41%           
=======================================
  Files          26       26           
  Lines         742      742           
  Branches      226      226           
=======================================
  Hits          708      708           
  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.

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