{"record":{"id":"3cd191a3daafa91e","repo":"NationalSecurityAgency/ghidra","slug":"password-entry-was-cancelled","errorCode":null,"errorMessage":"Password entry was cancelled","messagePattern":"Password entry was cancelled","errorType":"exception","errorClass":"CancelledSQLException","httpStatus":null,"severity":"info","filePath":"Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/BSimDBConnectTaskManager.java","lineNumber":76,"sourceCode":"\t\t// Use task to establish initial connection\n\t\tDBConnectTask connectTask = new DBConnectTask(connectionSupplier);\n\t\ttry {\n\t\t\t//@formatter:off\n            TaskBuilder.withTask(connectTask)\n                .setTitle(\"BSim DB Connection...\")\n                .setCanCancel(false)\n                .setHasProgress(false)\n                .launchModal();\n            //@formatter:on    \n\n\t\t\tsynchronized (BSimDBConnectTaskManager.this) {\n\t\t\t\tConnection c = connectTask.getConnection();\n\t\t\t\tif (c != null) {\n\t\t\t\t\treturn c;\n\t\t\t\t}\n\n\t\t\t\tif (isCancelled) {\n\t\t\t\t\tthrow new CancelledSQLException(\"Password entry was cancelled\");\n\t\t\t\t}\n\t\t\t\tif (exc instanceof SQLException e) {\n\t\t\t\t\tthrow e;\n\t\t\t\t}\n\t\t\t\tif (exc instanceof RuntimeException e) {\n\t\t\t\t\tthrow e;\n\t\t\t\t}\n\t\t\t\tthrow new RuntimeException(exc);\n\t\t\t}\n\t\t}\n\t\tfinally {\n\t\t\tsynchronized (BSimDBConnectTaskManager.this) {\n\t\t\t\tif (--count == 0) {\n\t\t\t\t\tclear();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/BSimDBConnectTaskManager.java#L58-L94","documentation":"Thrown by BSimDBConnectTaskManager.getConnection() as a CancelledSQLException when the modal connection task completed without establishing a connection and the user cancelled it (isCancelled flag is true). This occurs because password entry is performed through a modal Swing dialog; cancelling it sets the flag and no connection is returned.","triggerScenarios":"The BSim database connection password dialog is shown (initial connection or re-auth) and the user clicks Cancel/escapes the dialog, leaving connectTask with a null connection.","commonSituations":"User dismisses the password prompt intentionally; dialog is cancelled by an unrelated windowing event; automated test that does not provide a password.","solutions":["This is informational — re-attempt the connection and provide the password.","In headless/automated contexts, supply credentials programmatically so no modal dialog is required.","If cancellation is expected, catch CancelledSQLException and treat it as a user-initiated abort."],"exampleFix":"// before\nConnection c = connectTaskManager.getConnection(supplier); // user cancels dialog -> CancelledSQLException\n// after\ntry {\n    Connection c = connectTaskManager.getConnection(supplier);\n} catch (CancelledSQLException e) {\n    // user cancelled; abort gracefully\n    return;\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    Connection c = connectTaskManager.getConnection(supplier);\n} catch (CancelledSQLException e) {\n    // user-initiated cancellation; abort the operation gracefully\n    return;\n}","preventionTips":["Treat CancelledSQLException as an expected, non-fatal user abort.","In headless contexts, supply credentials programmatically to avoid the modal dialog.","Do not retry automatically on cancellation; surface the abort to the caller."],"tags":["bsim","database","authentication","swing","user-cancel"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}