fix: masquer les erreurs SQL des connecteurs web
This commit is contained in:
17
server/webImportSourcesError.test.ts
Normal file
17
server/webImportSourcesError.test.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { WEB_IMPORT_SOURCE_SAVE_ERROR, getSafeWebImportSourceError } from "./webImportSourcesError";
|
||||
|
||||
describe("getSafeWebImportSourceError", () => {
|
||||
it("never returns the SQL statement or connector parameters to the client", () => {
|
||||
const databaseError = new Error(
|
||||
"Failed query: insert into `webImportSources` (...) values (...) params: amazon@example.fr, secret-value",
|
||||
);
|
||||
|
||||
const safeError = getSafeWebImportSourceError(databaseError);
|
||||
|
||||
expect(safeError.code).toBe("INTERNAL_SERVER_ERROR");
|
||||
expect(safeError.message).toBe(WEB_IMPORT_SOURCE_SAVE_ERROR);
|
||||
expect(safeError.message).not.toContain("insert into");
|
||||
expect(safeError.message).not.toContain("secret-value");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user