{"record":{"id":"c28200fe457f8700","repo":"SonarSource/sonarqube","slug":"the-s-parameter-is-missing","errorCode":null,"errorMessage":"The '%s' parameter is missing","messagePattern":"The '(.+?)' parameter is missing","errorType":"validation","errorClass":"PasswordException","httpStatus":400,"severity":"error","filePath":"server/sonar-webserver-webapi/src/main/java/org/sonar/server/user/ws/ChangePasswordAction.java","lineNumber":184,"sourceCode":"    }\n  }\n\n  private static void assertPasswordFormatIsValid(String newPassword) throws PasswordException {\n    try {\n      checkArgument(newPassword.length() >= MIN_PASSWORD_LENGTH, \"Password must be at least %s characters long\", MIN_PASSWORD_LENGTH);\n      checkArgument(UPPERCASE_PATTERN.matcher(newPassword).find(), \"Password must contain at least one uppercase character\");\n      checkArgument(LOWERCASE_PATTERN.matcher(newPassword).find(), \"Password must contain at least one lowercase character\");\n      checkArgument(DIGIT_PATTERN.matcher(newPassword).find(), \"Password must contain at least one digit\");\n      checkArgument(SPECIAL_CHARACTER_PATTERN.matcher(newPassword).find(), \"Password must contain at least one special character\");\n    } catch (IllegalArgumentException e) {\n      throw new PasswordException(e.getMessage());\n    }\n  }\n\n  private static String getParamOrThrow(HttpRequest request, String key) throws PasswordException {\n    String value = request.getParameter(key);\n    if (isNullOrEmpty(value)) {\n      throw new PasswordException(format(MSG_PARAMETER_MISSING, key));\n    }\n    return value;\n  }\n\n  private void checkPreviousPassword(DbSession dbSession, UserDto user, String password) throws PasswordException {\n    try {\n      localAuthentication.authenticate(dbSession, user, password, AuthenticationEvent.Method.BASIC);\n    } catch (AuthenticationException ex) {\n      throw new PasswordException(OLD_PASSWORD_INCORRECT, \"Incorrect password\");\n    }\n  }\n\n  private static void checkNewPasswordSameAsOld(String newPassword, String previousPassword) throws PasswordException {\n    if (previousPassword.equals(newPassword)) {\n      throw new PasswordException(NEW_PASSWORD_SAME_AS_OLD, \"Password must be different from old password\");\n    }\n  }\n","sourceCodeStart":166,"sourceCodeEnd":202,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/server/sonar-webserver-webapi/src/main/java/org/sonar/server/user/ws/ChangePasswordAction.java#L166-L202","documentation":"getParamOrThrow converts a missing/empty required parameter (login, previousPassword, or newPassword) into a PasswordException with MSG_PARAMETER_MISSING, so change-password callers get a consistent 400-style error naming the missing parameter instead of an NPE downstream.","triggerScenarios":"POST api/users/change_password without login, previous_password, or new_password, or with any of them set to an empty string.","commonSituations":"Forms/clients omitting the old-password field when the caller is an administrator assuming it is optional; empty request bodies; parameter name typos in scripts.","solutions":["Provide all required parameters: login, previous_password, new_password","Check for empty-string values in the client before sending","Fix parameter name spelling to match the API contract"],"exampleFix":"// before\nPOST /api/users/change_password?login=jdoe&new_password=X   // missing previous_password\n// after\nPOST /api/users/change_password?login=jdoe&previous_password=OLD&new_password=X","handlingStrategy":"validation","validationCode":"for (const [k, v] of {login, previous_password, new_password}) {\n  if (v == null || v === '') throw new Error(`Missing required parameter: ${k}`);\n}","typeGuard":"function hasValue(v) { return typeof v === 'string' && v.length > 0; }","tryCatchPattern":"try { await changePassword(params); } catch (e) { if (/parameter is missing/.test(e.message)) { const missing = e.message.match(/'(.*)'/)[1]; throw new Error(`Provide ${missing} before retrying`); } throw e; }","preventionTips":["Validate all required fields non-empty in the client before submitting","Never send empty strings for optional-but-checked parameters","Keep parameter names in a shared constant/API client to avoid typos"],"tags":["missing-parameter","users","api","validation"],"backgroundTag":"missing-required-argument","analyzedSha":"184c821202192afc1c599fc912d0889b69fffa53","analyzedAt":"2026-09-09T12:23:51.573Z","contentChangedAt":"2026-09-09T12:23:51.573Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}