fix(mobile-api): event errors use the portal's details/errors contract

The portal forwards only code, errors and flat details from a ProblemDetail, so
the failing field and the TEAM_NOT_SAVED event uuid move into details and the
missing-field list into errors.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
This commit is contained in:
ngqileandClaude Opus 5.5 committed 2026-11-27 00:25:55 +08:00
1 parent c908fbe9fc
commit 2efdcba1ae
2 files changed
+17 -6

No files matched your search

@@ -135,7 +135,7 @@ public class AdminEventService {
List<String> missing = in.entrySet().stream().filter(e -> !StringUtils.hasText(e.getValue())).map(Map.Entry::getKey).toList();
if (!missing.isEmpty()) {
CodedResponseStatusException e = error(HttpStatus.BAD_REQUEST, "Required: " + String.join(", ", missing), "REQUIRED_FIELD", missing.get(0));
e.getBody().setProperty("fields", missing);
e.getBody().setProperty("errors", missing);
throw e;
}
String name = r.name().trim();
@@ -200,7 +200,7 @@ public class AdminEventService {
} catch (RuntimeException ex) {
CodedResponseStatusException e = error(HttpStatus.BAD_GATEWAY,
"Event " + eventUuid + " was saved but its team was not; save the team again", "TEAM_NOT_SAVED", null);
e.getBody().setProperty("eventUuid", String.valueOf(eventUuid));
e.getBody().setProperty("details", Map.of("eventUuid", String.valueOf(eventUuid)));
throw e;
}
}
@@ -248,10 +248,10 @@ public class AdminEventService {
return error(HttpStatus.NOT_FOUND, "Event not found", "EVENT_NOT_FOUND", null);
}
/** field, when given, rides on the ProblemDetail body next to code, so the portal can mark the failing input. */
/** field, when given, rides in the ProblemDetail's details (the portal forwards code, errors and flat details only). */
private static CodedResponseStatusException error(HttpStatus status, String reason, String code, String field) {
CodedResponseStatusException e = new CodedResponseStatusException(status, reason, code);
if (field != null) e.getBody().setProperty("field", field);
if (field != null) e.getBody().setProperty("details", Map.of("field", field));
return e;
}
}