{"record":{"id":"9ca65d6d1d10c47d","repo":"zaproxy/zaproxy","slug":"start-gui-cmdline-session-path-invalid","errorCode":null,"errorMessage":"start.gui.cmdline.session.path.invalid","messagePattern":"start\\.gui\\.cmdline\\.session\\.path\\.invalid","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"zap/src/main/java/org/zaproxy/zap/GuiBootstrap.java","lineNumber":258,"sourceCode":"                        view.getMainFrame().setVisible(true);\n\n                        boolean createNewSession = true;\n                        if (getArgs().isEnabled(CommandLine.SESSION)\n                                && getArgs().isEnabled(CommandLine.NEW_SESSION)) {\n                            view.showWarningDialog(\n                                    Constant.messages.getString(\n                                            \"start.gui.cmdline.invalid.session.options\",\n                                            CommandLine.SESSION,\n                                            CommandLine.NEW_SESSION,\n                                            Constant.getZapHome()));\n\n                        } else if (getArgs().isEnabled(CommandLine.SESSION)) {\n                            String path = getArgs().getArgument(CommandLine.SESSION);\n                            Path sessionPath = null;\n                            try {\n                                sessionPath = SessionUtils.getSessionPath(path);\n                            } catch (IllegalArgumentException e) {\n                                LOGGER.warn(\n                                        \"An error occurred while resolving the session path:\", e);\n                            }\n\n                            if (sessionPath == null) {\n                                view.showWarningDialog(\n                                        Constant.messages.getString(\n                                                \"start.gui.cmdline.session.path.invalid\", path));\n                            } else if (!Files.exists(sessionPath)) {\n                                view.showWarningDialog(\n                                        Constant.messages.getString(\n                                                \"start.gui.cmdline.session.does.not.exist\",\n                                                Constant.getZapHome()));\n\n                            } else {\n                                createNewSession =\n                                        !control.getMenuFileControl()\n                                                .openSession(\n                                                        sessionPath.toAbsolutePath().toString());","sourceCodeStart":240,"sourceCodeEnd":276,"githubUrl":"https://github.com/zaproxy/zaproxy/blob/9d1970a436b1b189bfb588fc88864c80d9baf6a5/zap/src/main/java/org/zaproxy/zap/GuiBootstrap.java#L240-L276","documentation":"Raised in GuiBootstrap.run when the -session command-line argument cannot be resolved to a valid session path. SessionUtils.getSessionPath throws IllegalArgumentException for invalid paths; the code logs a warning and, seeing a null sessionPath, shows a warning dialog with this i18n message and aborts opening the session in the GUI.","triggerScenarios":"Starting ZAP GUI with -session <path> where the path is not a valid session path (nonexistent file, missing/incorrect .session extension, or path not under the sessions directory as enforced by SessionUtils.getSessionPath).","commonSituations":"Typos in the session path on the command line; passing a session name without the expected extension or directory; moving/deleting session files between runs; relative vs absolute path confusion.","solutions":["Verify the -session argument points to an existing ZAP session file with the correct extension and location.","Use an absolute path or a path consistent with the configured sessions directory.","List the sessions directory to find the correct session name, or omit -session and pick the session in the GUI.","Check the ZAP log for the 'An error occurred while resolving the session path' warning to see the underlying IllegalArgumentException."],"exampleFix":"// before\nzap.sh -session /nonexistent/mysession\n\n// after\nzap.sh -session /home/user/ZAP/sessions/mysession.session","handlingStrategy":"validation","validationCode":"Path p = Paths.get(sessionArg);\nboolean valid = Files.isRegularFile(p) && p.toString().endsWith(\".session\");\nif (!valid) { System.err.println(\"Invalid -session path: \" + sessionArg); }","typeGuard":null,"tryCatchPattern":"try { Path sp = SessionUtils.getSessionPath(path); } catch (IllegalArgumentException e) { LOGGER.warn(\"Invalid session path\", e); view.showWarningDialog(msg); }","preventionTips":["Pass an absolute path to an existing .session file","Confirm the session file exists before launching with -session","Keep session files in the configured sessions directory","Check ZAP startup logs for path-resolution warnings"],"tags":["cli","session","file-path","startup"],"backgroundTag":"invalid-file-path","analyzedSha":"9d1970a436b1b189bfb588fc88864c80d9baf6a5","analyzedAt":"2026-09-05T19:26:59.356Z","contentChangedAt":"2026-09-05T19:26:59.356Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}