yudaocode/SpringBoot-Labs · warning · java.lang.RuntimeException
小朋友,你的账号密码不正确哟!
Error message
小朋友,你的账号密码不正确哟!
What it means
Intentional demo exception in the lab-71 IDEA HTTP Client tutorial. The login endpoint hard-codes a single credential pair (yudaoyuanma/123456); any other combination throws a RuntimeException with this playful message. Since there is no @ExceptionHandler, Spring returns HTTP 500 with the message in the error body.
Source
Thrown at lab-71-http-debug/lab-71-idea-http-client/src/main/java/cn/iocoder/springboot/lab71/controller/UserController.java:30
* 用户 Controller
*
* 示例代码,纯粹为了演示。
*/
@RestController
public class UserController {
private final Logger logger = LoggerFactory.getLogger(getClass());
@PostMapping("/user/login")
public Map<String, Object> login(@RequestParam("username") String username,
@RequestParam("password") String password) {
if ("yudaoyuanma".equals(username) && "123456".equals(password)) {
Map<String, Object> tokenMap = new HashMap<>();
tokenMap.put("userId", 1);
tokenMap.put("token", "token001");
return tokenMap;
}
throw new RuntimeException("小朋友,你的账号密码不正确哟!");
}
@GetMapping("/user/get-current")
public Map<String, Object> getCurrentUser(@RequestHeader("Authorization") String authorization,
@RequestParam("full") boolean full) {
if ("token001".equals(authorization)) {
Map<String, Object> userInfo = new HashMap<>();
userInfo.put("id", 1);
// full 为 true 时,获得完整信息
if (full) {
userInfo.put("nickname", "芋道源码");
userInfo.put("gender", 1);
}
return userInfo;
}
throw new RuntimeException("小朋友,你没有登录哟!");
}
View on GitHub (pinned to 6c12efaed0)
Solutions
- Send exactly username=yudaoyuanma and password=123456 as request parameters to get the token 'token001'.
- If you extended the demo, register the credentials properly instead of relying on the hard-coded pair.
- Add a @ControllerAdvice exception handler returning 400/401 instead of an unhandled 500.
Example fix
// before
throw new RuntimeException("小朋友,你的账号密码不正确哟!");
// after — proper status code via a handled exception
throw new ResponseStatusException(HttpStatus.UNAUTHORIZED, "账号密码不正确"); Defensive patterns
Strategy: validation
Validate before calling
// Validate before calling
if (!"yudaoyuanma".equals(username) || !"123456".equals(password)) {
// don't call /user/login; show a credential error locally
} Try / catch
// IDEA HTTP client / RestTemplate
try {
ResponseEntity<Map> resp = restTemplate.postForEntity(url + "/user/login?username={u}&password={p}", null, Map.class, user, pass);
} catch (HttpClientErrorException | HttpServerErrorException e) {
// 500 with message body for wrong credentials in this demo
log.warn("login failed: {}", e.getResponseBodyAsString());
} Prevention
- Use the exact demo credentials from the tutorial's .http file.
- Send credentials as request parameters, not JSON body.
- For real apps return 401/400 via exception handlers, never 500 for auth failures.
When it happens
Trigger: POST /user/login with any username other than 'yudaoyuanma' or any password other than '123456' (form/RequestParam fields, not JSON body).
Common situations: Following the tutorial's .http request files but mistyping the demo credentials; testing what an error response looks like in the IDEA HTTP client (that is the point of the lab); sending credentials as JSON body instead of request parameters so both fields are null/wrong.
Related errors
AI-assisted analysis of yudaocode/SpringBoot-Labs@6c12efaed0 (2026-08-14).
Data as JSON: /api/errors/de893e35b606c663.
Report an issue: GitHub.