修复V3空业务根回调处理
This commit is contained in:
@@ -226,6 +226,9 @@ public class ReservationAiTaskIntakeServiceImpl implements ReservationAiTaskInta
|
|||||||
JsonNode messageEvents = root.path("message_events");
|
JsonNode messageEvents = root.path("message_events");
|
||||||
JsonNode unhandledIntents = root.path("unhandled_current_intents");
|
JsonNode unhandledIntents = root.path("unhandled_current_intents");
|
||||||
int itemCount = messageEvents.size() + unhandledIntents.size();
|
int itemCount = messageEvents.size() + unhandledIntents.size();
|
||||||
|
if (itemCount <= 0) {
|
||||||
|
throw error(HttpStatus.BAD_REQUEST, "TASK_RESULTS_EMPTY", "message_events 和 unhandled_current_intents 不能同时为空。");
|
||||||
|
}
|
||||||
String requestPayloadSha256 = sha256(rawBody == null ? "" : rawBody);
|
String requestPayloadSha256 = sha256(rawBody == null ? "" : rawBody);
|
||||||
String batchIdempotencyKey = sha256(BATCH_KEY_PREFIX + "|" + sourceMessageId + "|" + requestPayloadSha256);
|
String batchIdempotencyKey = sha256(BATCH_KEY_PREFIX + "|" + sourceMessageId + "|" + requestPayloadSha256);
|
||||||
|
|
||||||
|
|||||||
@@ -805,6 +805,38 @@ class SuperAgentTaskResultControllerTest {
|
|||||||
assertThat(transitionCount).isEqualTo(1L);
|
assertThat(transitionCount).isEqualTo(1L);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void shouldRejectEmptyV3BusinessRootWithoutPersistingBatch() throws Exception {
|
||||||
|
SourceMessageCaptureResult source = captureSourceMessage("mail-v3-empty-business-root-001");
|
||||||
|
String body = """
|
||||||
|
{
|
||||||
|
"source_message": {
|
||||||
|
"source_message_id": "mail-v3-empty-business-root-001",
|
||||||
|
"subject": "Empty business root",
|
||||||
|
"from": null,
|
||||||
|
"cc": [],
|
||||||
|
"received_at": null,
|
||||||
|
"source_channel": "Email"
|
||||||
|
},
|
||||||
|
"message_events": [],
|
||||||
|
"case_candidates": [],
|
||||||
|
"extraction_warnings": [],
|
||||||
|
"unhandled_current_intents": []
|
||||||
|
}
|
||||||
|
""";
|
||||||
|
|
||||||
|
mockMvc.perform(signedPost(body, "nonce-v3-empty-business-root-001"))
|
||||||
|
.andExpect(status().isBadRequest())
|
||||||
|
.andExpect(jsonPath("$.error_code").value("TASK_RESULTS_EMPTY"));
|
||||||
|
|
||||||
|
Long batchCount = jdbcTemplate.queryForObject("""
|
||||||
|
SELECT COUNT(*)
|
||||||
|
FROM workflow_reservation_ai_batch
|
||||||
|
WHERE source_message_id = ?
|
||||||
|
""", Long.class, source.inboxId());
|
||||||
|
assertThat(batchCount).isZero();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void shouldPersistAdapterContractErrorWhenV3EventRouteCannotBeDerived() throws Exception {
|
void shouldPersistAdapterContractErrorWhenV3EventRouteCannotBeDerived() throws Exception {
|
||||||
SourceMessageCaptureResult source = captureSourceMessage("mail-v3-adapter-error-001");
|
SourceMessageCaptureResult source = captureSourceMessage("mail-v3-adapter-error-001");
|
||||||
|
|||||||
Reference in New Issue
Block a user