Code RoomNot found returns 200
MediumPrep Room Coding #1987

Not found returns 200

Code reviewDatabases & SQLMid–Senior~20 min

Review this Java Spring controller that fetches a user.

What a strong answer looks like

Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix, specific and kind.

0:00 of about 20 min
Mark a line and say what kind of problem it is.0 findings
1@GetMapping("/users/{id}")
2public ResponseEntity<Map<String,Object>> getUser(@PathVariable String id) {
3 User u = repo.findById(id).orElse(null);
4 Map<String,Object> body = new HashMap<>();
5 if (u == null) {
6 body.put("error", "not found");
7 return ResponseEntity.ok(body);
8 }
9 body.put("id", u.getId());
10 body.put("name", u.getName());
11 return ResponseEntity.ok(body);
12}
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.