feat(sqlite): restore rc4 legacy support via optional feature

This commit is contained in:
zipg authored and GitHub committed 2026-08-26 17:21:53 +08:00
1 parent 4b4b4ac2dd
commit b5124baca9
22 files changed
+232 -57

No files matched your search

@@ -1,5 +1,5 @@
import { describe, expect, it } from "vitest";
import { appendConnectionErrorHints } from "@/lib/connection/connectionErrorHints";
import { appendConnectionErrorHints, isSqliteMissingEncryptionPasswordFailure } from "@/lib/connection/connectionErrorHints";
import type { ConnectionConfig } from "@/types/database";
function mysqlConfig(urlParams: string | undefined): ConnectionConfig {
@@ -40,6 +40,14 @@ const t = (key: string) => {
};
describe("appendConnectionErrorHints", () => {
it("recognizes an encrypted SQLite file that was first opened without a password", () => {
const config = { ...mysqlConfig(undefined), db_type: "sqlite" as const, host: "/tmp/encrypted.db", port: 0 };
expect(isSqliteMissingEncryptionPasswordFailure(config, "Selected file is not a valid SQLite database file.")).toBe(true);
expect(isSqliteMissingEncryptionPasswordFailure({ ...config, password: "wrong" }, "Selected file is not a valid SQLite database file.")).toBe(false);
expect(isSqliteMissingEncryptionPasswordFailure(config, "SQLite connection failed: unable to open database file")).toBe(false);
});
it("adds a MySQL TLS hint for non-disabled TLS failures", () => {
const message = appendConnectionErrorHints(mysqlConfig("ssl-mode=preferred"), "MySQL connection failed: TLS handshake failed", t);
@@ -72,6 +72,11 @@ export function isMysqlMissingPasswordFailure(config: ConnectionConfig, message:
return /access denied for user[\s\S]*using password:\s*no/i.test(message);
}
export function isSqliteMissingEncryptionPasswordFailure(config: ConnectionConfig, message: string): boolean {
if (config.db_type !== "sqlite" || config.password) return false;
return /Selected file is not a valid SQLite database file/i.test(message);
}
export function isJdbcMissingRuntimeDependencyError(message: string): boolean {
return /Missing Java class|NoClassDefFoundError|ClassNotFoundException/i.test(message);
}