fix(aihr): hide org sync error payloads
This commit is contained in:
+4
-4
@@ -224,7 +224,7 @@ public class AihrOrgSyncService {
|
||||
try {
|
||||
return fetchSnapshot(baseUrl, token, req, resourceType, pageSize, maxPages);
|
||||
} catch (Exception e) {
|
||||
String warning = "外部 " + resourceType + " 快照拉取失败,已用员工字段兜底: " + e.getMessage();
|
||||
String warning = "外部 " + resourceType + " 快照拉取失败,已用员工字段兜底: " + AihrSensitiveText.forModel(e.getMessage());
|
||||
warnings.add(warning);
|
||||
log.warn(warning);
|
||||
return List.of();
|
||||
@@ -286,7 +286,7 @@ public class AihrOrgSyncService {
|
||||
}
|
||||
return fetchedToken;
|
||||
} catch (Exception e) {
|
||||
throw new IllegalStateException("外部组织同步令牌获取失败: " + e.getMessage(), e);
|
||||
throw new IllegalStateException("外部组织同步令牌获取失败: " + AihrSensitiveText.forModel(e.getMessage()), e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -312,7 +312,7 @@ public class AihrOrgSyncService {
|
||||
.build()
|
||||
.send(builder.build(), HttpResponse.BodyHandlers.ofString(StandardCharsets.UTF_8));
|
||||
if (response.statusCode() < 200 || response.statusCode() >= 300) {
|
||||
throw new IllegalStateException("HTTP " + response.statusCode() + ": " + truncate(response.body(), 200));
|
||||
throw new IllegalStateException("HTTP " + response.statusCode() + "(外部响应体已隐藏)");
|
||||
}
|
||||
JsonNode root = objectMapper.readTree(response.body());
|
||||
if (root.has("success") && !root.path("success").asBoolean()) {
|
||||
@@ -320,7 +320,7 @@ public class AihrOrgSyncService {
|
||||
}
|
||||
return root;
|
||||
} catch (Exception e) {
|
||||
throw new IllegalStateException(e.getMessage(), e);
|
||||
throw new IllegalStateException(AihrSensitiveText.forModel(e.getMessage()), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
@@ -41,12 +41,15 @@ class AihrSensitiveTextTest {
|
||||
String sopSource = Files.readString(source("AihrSopSeedService.java"));
|
||||
String interviewSource = Files.readString(source("AihrInterviewService.java"));
|
||||
String speechSource = Files.readString(source("AihrSpeechService.java"));
|
||||
String orgSyncSource = Files.readString(source("AihrOrgSyncService.java"));
|
||||
|
||||
assertTrue(modelSource.contains("AihrSensitiveText.forModel(prompt)"));
|
||||
assertTrue(sopSource.contains("AihrSensitiveText.forModel(renderPrompt(prompt.template(), queryText, context))"));
|
||||
assertTrue(sopSource.contains("AihrSensitiveText.forModel(\"\"\""));
|
||||
assertTrue(interviewSource.contains("AihrSensitiveText.personName(candidate.name(), \"候选人\")"));
|
||||
assertTrue(speechSource.contains("AihrSensitiveText.forModel(text.trim())"));
|
||||
assertTrue(orgSyncSource.contains("外部响应体已隐藏"));
|
||||
assertTrue(orgSyncSource.contains("AihrSensitiveText.forModel(e.getMessage())"));
|
||||
}
|
||||
|
||||
private static Path source(String fileName) {
|
||||
|
||||
Reference in New Issue
Block a user