iflytek/astron-agent · warning
Failed to normalize publish approval snapshot spaceId
Error message
Failed to normalize publish approval snapshot spaceId
What it means
A warn log when the publish snapshot JSON in the submit DTO cannot be parsed or modified while injecting the normalized spaceId. Approval decisions are unaffected because they use the DTO's spaceId field; only the audit snapshot loses the spaceId injection.
Solutions
- Validate/serialize publishSnapshot as valid JSON on the client before submitting
- Guard the normalization with a null/empty check before parsing
- Log the offending snapshot content (truncated) to diagnose client payloads
Example fix
// before
JSONObject snapshot = JSON.parseObject(submitDto.getPublishSnapshot());
// after
if (submitDto.getPublishSnapshot() != null && !submitDto.getPublishSnapshot().isBlank()) {
JSONObject snapshot = JSON.parseObject(submitDto.getPublishSnapshot());
snapshot.put("spaceId", submitDto.getSpaceId());
submitDto.setPublishSnapshot(snapshot.toJSONString());
} Defensive patterns
Strategy: validation
When it happens
Trigger: submitIfRequired is called with publishSnapshot that is null, empty, or invalid JSON, so JSON.parseObject throws.
Common situations: Clients posting approval submissions with a malformed or missing publishSnapshot field; older clients sending non-JSON snapshot payloads.
Understand the failure class
Background: JSON parse error: "Unexpected token" / "not valid JSON" / "failed to parse" — what JSON parsers are really complaining about — this error's family across 45 libraries.
Related errors
- 9020
- The lengthRange must be an array of integers
- Invalid lengthRange format
- The separator must be an array of strings
- Invalid separator format
AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12).
Data as JSON: /api/errors/0622addc2122de27.
Report an issue: GitHub.
Appendix: source
Thrown at console/backend/hub/src/main/java/com/iflytek/astron/console/hub/service/publish/impl/PublishApprovalServiceImpl.java:259
private SpaceTypeEnum resolveSpaceType(Long spaceId) {
if (spaceId == null) {
return null;
}
return spaceService.getSpaceType(spaceId);
}
private void normalizePublishSnapshotSpaceId(PublishApprovalSubmitDto submitDto) {
if (StringUtils.isBlank(submitDto.getPublishSnapshot())) {
return;
}
try {
JSONObject snapshot = JSON.parseObject(submitDto.getPublishSnapshot());
snapshot.put("spaceId", submitDto.getSpaceId());
submitDto.setPublishSnapshot(snapshot.toJSONString());
} catch (Exception ex) {
// Snapshot is auxiliary audit data; approval decisions use the normalized DTO spaceId.
log.warn("Failed to normalize publish approval snapshot spaceId", ex);
}
}
private boolean isOwnerOrAdmin(SpaceRoleEnum role) {
return SpaceRoleEnum.OWNER == role || SpaceRoleEnum.ADMIN == role;
}
private boolean isApprovalEnabledPublishType(PublishApprovalTypeEnum publishType) {
return PublishApprovalTypeEnum.MARKET == publishType || PublishApprovalTypeEnum.API == publishType;
}
private void validateApprovalTarget(PublishApprovalSubmitDto submitDto) {
if (PublishApprovalResourceTypeEnum.BOT == submitDto.getResourceType()) {
Integer botId = parseBotId(submitDto.getResourceId());
int hasPermission = chatBotBaseMapper.checkBotPermission(
botId,
submitDto.getRequesterUid(),
submitDto.getSpaceId());View on GitHub (pinned to 5e758547a8)