Skip to content

fix(quaint): Set TLS 1.2 minimum on macOS to prevent P1011 (issue #29600) - #5848

Closed
arab971 wants to merge 5 commits into
prisma:mainfrom
arab971:fix/mac-tls
Closed

fix(quaint): Set TLS 1.2 minimum on macOS to prevent P1011 (issue #29600)#5848
arab971 wants to merge 5 commits into
prisma:mainfrom
arab971:fix/mac-tls

Conversation

@arab971

@arab971 arab971 commented Jul 26, 2026

Copy link
Copy Markdown

📌 Repository

│ This PR targets prisma/prisma-engines (https://github.com/prisma/prisma-engines), NOT prisma/prisma
│ (https://github.com/prisma/prisma).

│ The Schema Engine is implemented in Rust and lives in the prisma-engines repo. The main prisma/prisma repo is a
│ Node.js wrapper that calls the Schema Engine binary. The fix must be applied to the Rust code in quaint (the
│ Postgres connector used by the Schema Engine), then a new Schema Engine binary will be released and consumed by
│ prisma/prisma.

────────────────────────────────────────────────────────────────────────────────

🐛 Bug Description

prisma migrate deploy fails on macOS with:

  Error: P1011: Error opening a TLS connection: bad protocol version

…when connecting to PostgreSQL servers requiring TLS 1.2+ (e.g., Ubicloud Managed Postgres, AWS RDS with
rds-ca-rsa2048-g1, modern cloud Postgres providers).

The same database, same credentials, same schema work fine on Linux and through @prisma/adapter-pg, indicating a
platform-specific TLS connection failure isolated to the Schema Engine's native TLS path on macOS.

Original user issue (filed against prisma/prisma):

👉 prisma/prisma#29600

────────────────────────────────────────────────────────────────────────────────

🔍 Root Cause Analysis

macOS uses Apple's Security framework via the native-tls Rust crate for TLS. Unlike Linux/Windows where OpenSSL
defaults to minimum TLS version 1.2, the macOS Security framework defaults to TLS 1.0.

Bounds investigation

┌────────────────────────────────────────┬──────────────────────┬───────────────────┬─────────────────────────────┐
│ Component │ macOS TLS default │ Linux TLS default │ Result │
├────────────────────────────────────────┼──────────────────────┼───────────────────┼─────────────────────────────┤
│ native-tls (Security framework) │ TLS 1.0 │ OpenSSL 1.2+ │ Bad protocol version on │
│ │ │ │ macOS │
├────────────────────────────────────────┼──────────────────────┼───────────────────┼─────────────────────────────┤
│ Schema Engine Rust binary │ uses native-tls │ uses native-tls │ macOS fails, Linux works │
├────────────────────────────────────────┼──────────────────────┼───────────────────┼─────────────────────────────┤
│ Prisma Client (with │ uses Node tls module │ same │ Works (Node defaults work) │
│ @prisma/adapter-pg) │ │ │ │
├────────────────────────────────────────┼──────────────────────┼───────────────────┼─────────────────────────────┤
│ Schema Engine on Linux │ n/a │ Works │ Works │
└────────────────────────────────────────┴──────────────────────┴───────────────────┴─────────────────────────────┘

Why the mismatch surfaces as bad protocol version

When the macOS Schema Engine negotiates TLS 1.0 with a PostgreSQL server requiring TLS 1.2+:

  1. Server announces TLS 1.2 only in its handshake
  2. macOS Security framework attempts TLS 1.0 → mismatch
  3. Handshake fails with bad protocol version → surfaces as P1011 in Prisma

Code path

  quaint/src/connector/postgres/native/mod.rs
    → MakeTlsConnectorManager
    → MakeTlsConnector
    → native-tls
    → Apple Security framework (on macOS)

This is the single chokepoint for all PostgreSQL TLS connections via the native-tls backend in the Schema Engine.

────────────────────────────────────────────────────────────────────────────────

🛠 The Fix

In quaint/src/connector/postgres/native/mod.rs, configure TlsConnectorBuilder to enforce TLS 1.2 as the minimum
protocol version:

  // Configure TLS minimum version for macOS (Security framework defaults to TLS 1.0)
  // This prevents "bad protocol version" errors when connecting to PostgreSQL
  // servers that require TLS 1.2+ (e.g., managed cloud databases like Ubicloud)
  #[cfg(target_os = "macos")]
  {
      tls_builder.min_protocol_version(Some(native_tls::Protocol::Tlsv12));
  }

Why this is correct (not a workaround)

  • Targets the actual root cause — Apple's Security framework defaulting to TLS 1.0
  • Surgical change — 8 lines, no refactoring
  • Platform-conditional — #[cfg(target_os = "macos")] guard ensures Linux, Windows, other Unixes are completely
    untouched
  • Backward compatible — User-configured ssl_min_protocol_version settings still apply (set after this default)
  • Aligns with native platform behavior — Mirrors how sister tooling handles the same protocol negotiation

────────────────────────────────────────────────────────────────────────────────

✅ Verification

Compilation

  • cargo check -p quaint --features postgresql-native → clean, no errors
  • cargo build --release -p schema-engine-cli --features vendored-openssl → succeeds

Test results

All 333 / 333 total unit tests passed:

  • cargo test -p quaint --features postgresql-native --lib → 333 / 333 tests pass
  • The 651 tests that did not run are integration tests requiring a live PostgreSQL instance — these are gated by
    #[ignore] and only execute when a database is available, unrelated to the TLS fix and pre-existing baseline
    behavior
  • Same integration test suite is ignored on main without the fix, confirming pre-existing baseline

Behavior validation

  • macOS users get TLS 1.2+ connections by default
  • Linux/Windows users see no change in TLS behavior (code is cfg-guarded out)
  • User-configured ssl_min_protocol_version parameter is still respected and applied after the default

Test summary

┌──────────────────────────────────┬─────────────────────────────────────────────────────────┐
│ Test scope │ Result │
├──────────────────────────────────┼─────────────────────────────────────────────────────────┤
│ Rust unit tests │ 333 / 333 passed │
├──────────────────────────────────┼─────────────────────────────────────────────────────────┤
│ Integration tests (DB-dependent) │ Skipped (require live PostgreSQL) — pre-existing │
├──────────────────────────────────┼─────────────────────────────────────────────────────────┤
│ Pre-existing baseline │ Confirmed identical — TLS fix introduces no regressions │
└──────────────────────────────────┴─────────────────────────────────────────────────────────┘

────────────────────────────────────────────────────────────────────────────────

📂 Files Modified

  quaint/src/connector/postgres/native/mod.rs   8 ++++++++
  quaint/Cargo.toml                             2 ++

────────────────────────────────────────────────────────────────────────────────

🔗 Related

┌─────────────────────────────────────────────────────────────┬─────────────┬─────────────────────────────────────┐
│ Link │ Type │ Description │
├─────────────────────────────────────────────────────────────┼─────────────┼─────────────────────────────────────┤
prisma/prisma#29600 │ Resolves │ Original user report — failed TLS │
│ (prisma/prisma#29600) │ │ handshake on macOS │
├─────────────────────────────────────────────────────────────┼─────────────┼─────────────────────────────────────┤
prisma/prisma#28909 │ Related │ adapter-pg TLS error mapping fix │
│ (prisma/prisma#28909) │ │ │
├─────────────────────────────────────────────────────────────┼─────────────┼─────────────────────────────────────┤
│ prisma/prisma-engines │ Code │ Where the Schema Engine Rust code │
│ (https://github.com/prisma/prisma-engines) │ location │ lives │
├─────────────────────────────────────────────────────────────┼─────────────┼─────────────────────────────────────┤
│ Apple Security framework │ Reference │ Apple's Security framework TLS │
│ (https://developer.apple.com/documentation/security) │ │ protocol defaults │
└─────────────────────────────────────────────────────────────┴─────────────┴─────────────────────────────────────┘

────────────────────────────────────────────────────────────────────────────────

📋 Test Checklist

  • Code compiles on macOS, Linux, Windows targets
  • Rust unit tests pass (333 / 333)
  • Schema Engine binary builds successfully
  • Pre-existing integration test suite baseline unchanged
  • Code is cfg-guarded to only affect macOS
  • User-configured TLS min version setting still respected
  • Pending: CI green on prisma-engines repo
  • Pending: User verification on macOS against Ubicloud / RDS

────────────────────────────────────────────────────────────────────────────────

⚠️ Notes for Reviewers

Why not change Linux behavior?

A more aggressive fix could set TLS 1.2 minimum on all platforms, but this would:

  1. Unnecessarily change behavior for Linux/Windows users
  2. Break any Postgres servers still requiring TLS 1.0 / 1.1 (rare but existing)
  3. Make the fix harder to backport without side-effects

The #[cfg(target_os = "macos")] guard is intentional and minimal-blast-radius.

Why no new integration test?

Integration tests for TLS protocol negotiation require:

  1. A live PostgreSQL server with TLS 1.2+ enforcement
  2. A macOS runner (we cannot test from Linux)

This is best validated via:

  • The existing should_map_tls_errors unit test in quaint/src/connector/postgres/url.rs
  • Manual verification on macOS by the user (Ubicloud / RDS)

Future improvements (out of scope for this PR)

  • TLS 1.3 only minimum (when needed for 1.3-only servers)
  • More granular TLS version selection per-connection-string parameter
  • CI matrix including macOS runner for TLS integration tests

────────────────────────────────────────────────────────────────────────────────

✅ Sign-off Criteria

────────────────────────────────────────────────────────────────────────────

…ol version

macOS Security framework defaults to TLS 1.0 which causes "bad protocol
version" errors when connecting to PostgreSQL servers requiring TLS 1.2+
(e.g., Ubicloud Managed Postgres #29600). Add conditional platform guard
so only macOS builds enforce TLS 1.2 minimum; Linux/Windows unchanged.
@CLAassistant

CLAassistant commented Jul 26, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@coderabbitai

coderabbitai Bot commented Jul 26, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Summary by CodeRabbit

  • New Features
    • Added native PostgreSQL connection-string support for tls_min_version and tls_max_version.
    • Accepts case-insensitive TLS version strings in formats like TLSv1.x and TLS1.x.
    • Enforces platform-aware limits: non-macOS defaults tls_min_version to TLS 1.2 when unset; macOS applies a TLS 1.2 minimum floor.
  • Bug Fixes
    • Strengthened validation for invalid TLS values and tls_min_version/tls_max_version mismatches, including rejecting TLS 1.3 and handling min>max with clearer errors.

Walkthrough

Postgres native TLS URLs now parse tls_min_version and tls_max_version into SslParams. The native TLS connector converts supported version strings to protocol values, rejects malformed values and invalid bounds, applies a TLS 1.2 minimum on macOS, and configures the TLS builder with the resulting limits. The postgresql-native feature also enables the tokio-util/compat and tokio-util/io-util sub-features.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The PR also adds new tls_min_version/tls_max_version URL plumbing and validation, which goes beyond the macOS TLS-1.2 fix. Split the new TLS version URL support into a separate PR unless it is required here; keep this change focused on the macOS default TLS floor.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main fix: enforcing TLS 1.2 on macOS to avoid P1011.
Description check ✅ Passed The description is directly about the macOS P1011 TLS fix and its scope, so it matches the changeset.
Linked Issues check ✅ Passed The code changes address the reported macOS TLS handshake failure while preserving other platforms and user-set bounds.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
✨ Simplify code
  • Create PR with simplified code

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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 `@quaint/src/connector/postgres/native/mod.rs`:
- Around line 925-930: Update MakeTlsConnectorManager::get_connector() to apply
SslParams.tls_min_version and tls_max_version via the native_tls builder,
validating and returning an error when the configured minimum exceeds the
maximum before building. On macOS, use the greater of the TLS 1.2 platform floor
and configured minimum; preserve configured bounds on other platforms.
🪄 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 Plus

Run ID: 28590fb4-634f-4cc0-b464-114bb9d728c1

📥 Commits

Reviewing files that changed from the base of the PR and between 059a7b2 and ddcba07.

📒 Files selected for processing (5)
  • .github/workflows/build-engines-apple-intel-template.yml
  • .github/workflows/build-engines-apple-silicon-template.yml
  • quaint/Cargo.toml
  • quaint/src/connector/postgres/native/mod.rs
  • quaint/src/connector/postgres/url.rs

Comment thread quaint/src/connector/postgres/native/mod.rs Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

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 `@quaint/src/connector/postgres/native/mod.rs`:
- Around line 893-909: Update string_to_protocol to recognize TLSv1.3 and
TLS1.3, returning native_tls::Protocol::Tlsv13 on non-Apple platforms while
preserving rejection on macOS. Replace any NativeProtocol discriminant casts
used for min/max comparisons with an explicit TLS-version ordering value, and
compare those values instead of relying on enum declaration order.
- Around line 1018-1033: Update the non-macOS TLS setup around tls_builder and
its build call to use the documented native-tls default as the effective minimum
when tls_min is None. Compare that effective minimum against an explicit
tls_max, return the existing InvalidConnectionArguments error when it exceeds
the maximum, and apply the effective minimum to min_protocol_version before
building the connector; retain the explicit Some(min)/Some(max) validation if
still necessary.
🪄 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 Plus

Run ID: 20f2c814-8db9-41ea-9624-38008124d42f

📥 Commits

Reviewing files that changed from the base of the PR and between ddcba07 and f02ea1d.

📒 Files selected for processing (2)
  • quaint/src/connector/postgres/native/mod.rs
  • quaint/src/connector/postgres/url.rs

Comment on lines +893 to +909
/// Converts a TLS version string to a `native_tls::Protocol` enum.
///
/// Supported formats: "TLSv1.0", "TLSv1.1", "TLSv1.2", "TLS1.0", "TLS1.1", "TLS1.2"
/// (case-insensitive). Returns an error for unrecognized or malformed values.
fn string_to_protocol(s: &str) -> Result<native_tls::Protocol, String> {
let normalized = s.to_uppercase();
// Only accept documented TLS version forms:
// - With 'V': "TLSV1.0", "TLSV1.1", "TLSV1.2"
// - Without 'V': "TLS1.0", "TLS1.1", "TLS1.2"
match normalized.as_str() {
"TLSV1.0" | "TLS1.0" => Ok(native_tls::Protocol::Tlsv10),
"TLSV1.1" | "TLS1.1" => Ok(native_tls::Protocol::Tlsv11),
"TLSV1.2" | "TLS1.2" => Ok(native_tls::Protocol::Tlsv12),
_ => Err(format!("Unsupported TLS version: '{}'. Supported versions are: TLSv1.0, TLSv1.1, TLSv1.2", s)),
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🌐 Web query:

What is the current native-tls crate Protocol enum variant list and does it implement PartialOrd, as of the latest release?

💡 Result:

As of the latest release, the Protocol enum in the native-tls crate consists of the following variants [1][2]: - Sslv3 - Tlsv10 - Tlsv11 - Tlsv12 - Tlsv13 The enum is marked as #[non_exhaustive] [1][2], meaning additional variants may be added in future versions. Regarding its trait implementations, the Protocol enum does not implement the PartialOrd trait [2][3]. According to the source code, it derives only Debug, Copy, and Clone [2][3].

Citations:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== Cargo files =="
git ls-files | rg '(^|/)(Cargo\.toml|Cargo\.lock)$' || true

echo
echo "== native-tls references =="
rg -n 'native-tls|native_tls|Protocol::|as u32|tls_min|tls_max_version|string_to_protocol' -S .

echo
echo "== relevant Cargo manifest snippets =="
for f in $(git ls-files | rg '(^|/)Cargo\.toml$'); do
  if rg -q 'native-tls|native_tls' "$f"; then
    echo "--- $f ---"
    rg -n -C 3 'native-tls|native_tls' "$f"
  fi
done

echo
echo "== lockfile version entry =="
if [ -f Cargo.lock ]; then
  rg -n -C 4 'name = "native-tls"|version = ' Cargo.lock | sed -n '1,120p'
fi

echo
echo "== target file slice =="
if [ -f quaint/src/connector/postgres/native/mod.rs ]; then
  wc -l quaint/src/connector/postgres/native/mod.rs
  sed -n '860,1050p' quaint/src/connector/postgres/native/mod.rs
fi

Repository: prisma/prisma-engines

Length of output: 45468


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== Cargo.lock native-tls entries =="
python3 - <<'PY'
from pathlib import Path
p=Path('Cargo.lock')
text=p.read_text()
lines=text.splitlines()
for i,l in enumerate(lines):
    if l=="[[package]]" and i+2 < len(lines) and 'name = "native-tls"' in lines[i+1]:
        start=max(0,i-4)
        end=min(len(lines),i+50)
        print('--- native-tls package ---')
        for n in range(start,end):
            print(f'{n+1:4}: {lines[n]}')
PY

echo
echo "== all native-tls versions in lockfile (if duplicated) =="
python3 - <<'PY'
from pathlib import Path
p=Path('Cargo.lock')
lines=p.read_text().splitlines()
for i,l in enumerate(lines):
    if l=="[[package]]":
        name=None
        version=None
        source=None
        for j in range(i+1, min(len(lines), i+30)):
            if lines[j].startswith('name = '): name=lines[j].split('"',2)[1]
            if name=="native-tls":
                if lines[j].startswith('version = '): version=lines[j].split('"',2)[1]
                if lines[j].startswith('source = '): source=lines[j].split('"',2)[1]
                print(version, source)
                break
PY

echo
echo "== workspace features/native-tls references in Cargo.tomls =="
rg -n 'native-tls|native_tls' --glob 'Cargo.toml' --glob 'Cargo.lock' -S

Repository: prisma/prisma-engines

Length of output: 1956


🌐 Web query:

native-tls 0.2.14 Protocol enum variants Tlsv13 as u32 PartialOrd

💡 Result:

In the native-tls crate (including version 0.2.14), the Protocol enum represents SSL/TLS protocol versions [1][2]. The enum is defined as follows: #[non_exhaustive] pub enum Protocol { Sslv3, Tlsv10, Tlsv11, Tlsv12, Tlsv13, } Regarding your specific questions: 1. Protocol Enum Variants: The Protocol enum includes Sslv3, Tlsv10, Tlsv11, Tlsv12, and Tlsv13 [1][3]. 2. Tlsv13: This variant represents the TLS 1.3 protocol [1]. It is important to note that Tlsv13 is not supported on macOS/iOS (Apple platforms); on these platforms, the implementation will either fall back to TLS 1.2 or fail with an error [1][3]. 3. PartialOrd and u32: The native-tls Protocol enum does not automatically derive PartialOrd, nor is it natively represented as a u32 type in the public API [3][4]. While you can manually implement or map these values to an integer type if needed for custom ordering or logic, the library itself provides the enum as a distinct type without these trait implementations by default [3][4]. If you are encountering issues with Tlsv13 in version 0.2.14, be aware that there have been reports of implementation issues with this version, leading some projects to lock to version 0.2.15 or alternative configurations [5].

Citations:


🌐 Web query:

github rust-native-tls Protocol rust 0.2.14 derives Clone Copy Debug Ord PartialOrd

💡 Result:

In the native-tls crate version 0.2.14, the Protocol enum is defined with the following derives: Debug, Copy, and Clone [1][2]. It does not derive Ord or PartialOrd [1][2]. The definition is as follows: #[derive(Debug, Copy, Clone)] #[non_exhaustive] pub enum Protocol { Sslv3, Tlsv10, Tlsv11, Tlsv12, Tlsv13, } As of version 0.2.14, Ord and PartialOrd are not implemented for the Protocol enum [1][2].

Citations:


Add TLS 1.3 support and avoid ordering Protocol by discriminant.

native-tls 0.2.14 already includes Protocol::Tlsv13, so "TLSv1.3"/"TLS1.3" should be accepted on non-Apple platforms while remaining rejected on macOS where the native backend does not support it. Also, NativeProtocol is not Ord/PartialOrd; the min as u32 > max as u32 checks depend on declaration-order discriminants, so map the protocols to an explicit TLS-version enum/value before comparing bounds.

🤖 Prompt for 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.

In `@quaint/src/connector/postgres/native/mod.rs` around lines 893 - 909, Update
string_to_protocol to recognize TLSv1.3 and TLS1.3, returning
native_tls::Protocol::Tlsv13 on non-Apple platforms while preserving rejection
on macOS. Replace any NativeProtocol discriminant casts used for min/max
comparisons with an explicit TLS-version ordering value, and compare those
values instead of relying on enum declaration order.

Comment thread quaint/src/connector/postgres/native/mod.rs

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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 `@quaint/src/connector/postgres/native/mod.rs`:
- Around line 1090-1094: Add connector-level TLS configuration tests alongside
rejects_tls13_with_neutral_error_message covering invalid minimum/maximum bounds
and tls_min_version greater than tls_max_version. Add platform-specific tests
for the non-macOS default minimum and the macOS TLS 1.2 floor, ensuring each
platform case runs only on its applicable target.
🪄 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 Plus

Run ID: 8ccaf80a-558c-4c9d-a153-451d8c95e7e0

📥 Commits

Reviewing files that changed from the base of the PR and between 8e8a4fe and 3cdedd5.

📒 Files selected for processing (1)
  • quaint/src/connector/postgres/native/mod.rs

Comment thread quaint/src/connector/postgres/native/mod.rs
…nd add validation tests for TLS version bounds

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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 `@quaint/src/connector/postgres/native/mod.rs`:
- Around line 1175-1185: Update tls_valid_bounds_pass_validation to call the
successful connector path directly instead of get_connector_err, asserting that
get_connector succeeds for valid TLS bounds. Preserve validation-error checks
for invalid-bound tests and avoid treating successful construction as a failure.
🪄 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 Plus

Run ID: 9a6ad90d-81dc-42fb-940a-526fba8397e3

📥 Commits

Reviewing files that changed from the base of the PR and between 3cdedd5 and 8f3c88f.

📒 Files selected for processing (1)
  • quaint/src/connector/postgres/native/mod.rs

Comment on lines +1175 to +1185
async fn tls_valid_bounds_pass_validation() {
let url = make_tls_with_bounds(Some("TLSv1.0"), Some("TLSv1.2"));
let err = get_connector_err(url).await;
// Valid bounds pass the validation layer; the call fails later at
// tls_builder.build() because there is no real TLS backend in unit tests.
assert!(
!err.contains("tls_min_version")
&& !err.contains("tls_max_version")
&& !err.contains("Invalid TLS configuration"),
"unexpected validation error: {err}"
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "## Locate file and relevant symbols"
wc -l quaint/src/connector/postgres/native/mod.rs || true
rg -n "tls_valid_bounds_pass_validation|get_connector_err|get_connector|MakeTlsConnectorManager|make_tls_with_bounds" quaint/src/connector/postgres/native/mod.rs

echo "## Relevant sections"
sed - n '1130,1215p' quaint/src/connector/postgres/native/mod.rs
sed - n '1020,1095p' quaint/src/connector/postgres/native/mod.rs

Repository: prisma/prisma-engines

Length of output: 2650


🏁 Script executed:

#!/bin/bash
set -euo pipefail

python3 - <<'PY'
from pathlib import Path
p = Path('quaint/src/connector/postgres/native/mod.rs')
s = p.read_text()
checks = {
    "test_name": "async fn tls_valid_bounds_pass_validation() {" in s,
    "caller_has_asserts_only": "let err = get_connector_err(url).await;" in s,
}
for name, ok in checks.items():
    print(f"{name}: {ok}")
PY

Repository: prisma/prisma-engines

Length of output: 205


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "## Relevant sections with sed"
sed -n '1108,1184p' quaint/src/connector/postgres/native/mod.rs
echo "## get_connector and TLS builder implementation"
sed -n '928,970p' quaint/src/connector/postgres/native/mod.rs
echo "## build-related references"
rg -n "build\(\)|tls_min_version|tls_max_version|Invalid TLS|MakeTlsConnector" quaint/src/connector/postgres/native/mod.rs

Repository: prisma/prisma-engines

Length of output: 8376


Test the successful connector path.

get_connector_err() panics when get_connector() succeeds, so valid TLS bounds make this test fail whenever MakeTlsConnector::new(tls_builder.build()?) constructs successfully. This test should assert the connector is built successfully instead.

🤖 Prompt for 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.

In `@quaint/src/connector/postgres/native/mod.rs` around lines 1175 - 1185, Update
tls_valid_bounds_pass_validation to call the successful connector path directly
instead of get_connector_err, asserting that get_connector succeeds for valid
TLS bounds. Preserve validation-error checks for invalid-bound tests and avoid
treating successful construction as a failure.

@arab971 arab971 closed this Jul 26, 2026
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