{"record":{"id":"a361d545806c4ac8","repo":"NationalSecurityAgency/ghidra","slug":"invalid-in-url","errorCode":null,"errorMessage":"Invalid  in URL","messagePattern":"Invalid  in URL","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/BSimServerInfo.java","lineNumber":267,"sourceCode":"\t\tMatcher m = BAD_H2_CHARS_PATTERN.matcher(name);\n\t\tif (m.matches()) {\n\t\t\tthrow new IllegalArgumentException(\"Bad character in H2 database path. \" +\n\t\t\t\t\"Disallowed characters: \" + BAD_H2_CHARS);\n\t\t}\n\t\tString dbName = name.trim();\n\t\tdbName = dbName.replace(\"\\\\\", \"/\");\n\t\tif ((!dbName.startsWith(\"/\") && !isWindowsFilePath(dbName)) || dbName.endsWith(\"/\")) {\n\t\t\tthrow new IllegalArgumentException(\"Invalid absolute file path: \" + dbName);\n\t\t}\n\t\tif (!dbName.endsWith(H2_FILE_EXTENSION)) {\n\t\t\tdbName += H2_FILE_EXTENSION;\n\t\t}\n\t\treturn dbName;\n\t}\n\n\tprivate static String checkURLField(String val, String name) {\n\t\tif (StringUtils.isEmpty(val)) {\n\t\t\tthrow new IllegalArgumentException(\"Invalid \" + name + \" in URL\");\n\t\t}\n\t\treturn val.trim();\n\t}\n\n\t/**\n\t * Determine if this server info corresponds to Windows OS file path.\n\t * @return true if this server info corresponds to Windows OS file path.\n\t */\n\tpublic boolean isWindowsFilePath() {\n\t\treturn dbType == DBType.file && isWindowsFilePath(dbName);\n\t}\n\n\t/**\n\t * Check for Windows path after all '/' chars have been converted to '\\' chars.\n\t * Example:  {@code C:/a/b/c}\n\t * @param path absolute file path\n\t * @return true if path appears to be windows path with a drive letter\n\t */","sourceCodeStart":249,"sourceCodeEnd":285,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/BSimServerInfo.java#L249-L285","documentation":"Thrown by BSimServerInfo.checkURLField when constructing a BSimServerInfo from a URL and a required URL component (the host for postgres/elastic types, or the path/dbName) is null or empty. The message interpolates the field name (e.g. 'host' or 'path') so the literal string is 'Invalid <field> in URL'. BSim uses this to reject malformed server URLs early before any database connection is attempted.","triggerScenarios":"Constructing new BSimServerInfo(URL) where url.getHost() returns an empty string for a postgresql:// or https:// URL, or where the URL path is blank/empty (missing dbName). Also fires if the path is empty after stripping a leading slash for postgres/elastic types, or empty for a file: URL.","commonSituations":"Typo in a BSim URL string (e.g. 'postgresql:///dbname' with no host, or 'file://' with no path). Copy-pasting a URL that lost its host or path component. Building a URL programmatically and forgetting to set the host. URL-encoding issues that collapse the path to empty.","solutions":["Inspect the full URL string you pass to BSimServerInfo: ensure it contains a non-empty host for postgres/elastic URLs and a non-empty path (the dbName) for all types.","For postgres/elastic use the form 'postgresql://host:port/dbname' and for file use 'file:/absolute/path/to/db.h2'.","If building the URL from java.net.URL, verify url.getHost() and url.getPath() are non-empty before constructing BSimServerInfo.","URL-decode and trim the path mentally to confirm it is not whitespace-only."],"exampleFix":"// before\nBSimServerInfo info = new BSimServerInfo(new URL(\"postgresql:///mydb\"));\n// after\nBSimServerInfo info = new BSimServerInfo(new URL(\"postgresql://localhost:5432/mydb\"));","handlingStrategy":"validation","validationCode":"// Validate URL fields before constructing BSimServerInfo\nURL url = new URL(urlString);\nString host = url.getHost();\nString path = url.getPath();\nif (url.getProtocol().equals(\"postgresql\") || url.getProtocol().equals(\"https\")) {\n    if (host == null || host.trim().isEmpty()) {\n        throw new IllegalArgumentException(\"BSim URL is missing a host component\");\n    }\n}\nif (path == null || path.trim().isEmpty() || (path.strip().startsWith(\"/\") && path.strip().length() == 1 && path.strip().substring(1).isEmpty())) {\n    throw new IllegalArgumentException(\"BSim URL is missing a path/dbName component\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    BSimServerInfo info = new BSimServerInfo(new URL(urlString));\n} catch (IllegalArgumentException e) {\n    // message indicates which field ('host' or 'path') was empty\n    log.error(\"Invalid BSim URL '{}': {}\", urlString, e.getMessage());\n    throw e;\n}","preventionTips":["Centralize BSim URL construction in a helper that asserts host and path are non-empty.","Add a unit test that feeds canonical URLs and rejects ones missing host/path.","Never build BSim URLs by string concatenation without validating each component."],"tags":["bsim","url-parsing","configuration","validation"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}