iflytek/astron-agent · error · BusinessException
MODEL_NAME_EXISTED
MODEL_NAME_EXISTED
Error message
BusinessException(ResponseEnum.MODEL_NAME_EXISTED)
What it means
MODEL_NAME_EXISTED is thrown by saveOrUpdateModel when creating a new model (no id in request) whose name already exists for the same owner/space scope. A LambdaQueryWrapper matches on uid (and spaceId when provided) plus the model name; a non-null hit means the name is taken and creation aborts.
Solutions
- Choose a different, unique model name within the space.
- List existing models in the space first and reuse/update the existing model instead of creating a new one.
- If you meant to update, include the model's id in the request so the update branch runs.
- Check whether the duplicate is in the same spaceId vs personal (null spaceId) scope and move/rename accordingly.
Example fix
// before
POST /model/save { "modelName": "gpt4-main" } // already exists in this space
// after
POST /model/save { "modelName": "gpt4-main-v2" } // unique name Defensive patterns
Strategy: try-catch
Validate before calling
boolean nameTaken = modelService.listBySpace(spaceId, uid).stream().anyMatch(m -> m.getName().equals(request.getModelName()));
if (nameTaken) throw new IllegalStateException("model name already used in this space"); Try / catch
try { modelService.validateModel(req); } catch (BusinessException e) { if ("MODEL_NAME_EXISTED".equals(e.getCode())) { suggestAlternativeName(req.getModelName()); } throw e; } Prevention
- Uniqueness-check names against the space's model list in the UI before submit.
- Include the model id when the intent is update, not create.
- Adopt naming conventions (suffixes) to avoid collisions in shared spaces.
When it happens
Trigger: validateModel -> saveOrUpdateModel with a request lacking id but with modelName that already matches an existing model row for the same uid and spaceId (or uid with null spaceId for the personal scope).
Common situations: Trying to add a model with a name you already created in the same space; restoring/importing a model that duplicates an existing name; a renamed-then-recreated flow colliding with soft-deleted-looking duplicates (isDeleted=0 rows).
Understand the failure class
Background: "already exists" / EEXIST / FileAlreadyExistsException: what the 'file already exists' error means and how to fix it — this error's family across 37 libraries.
Related errors
AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12).
Data as JSON: /api/errors/a2971dd9c6725ea3.
Report an issue: GitHub.
Appendix: source
Thrown at console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/model/ModelService.java:413
private void saveOrUpdateModel(ModelValidationRequest request) {
final boolean isNew = (request.getId() == null);
final Long spaceId = SpaceInfoUtil.getSpaceId();
Model model;
if (isNew) {
// Duplicate name validation
LambdaQueryWrapper<Model> lqw = new LambdaQueryWrapper<Model>()
.eq(Model::getName, request.getModelName())
.eq(Model::getIsDeleted, 0);
if (spaceId != null) {
lqw.eq(Model::getSpaceId, spaceId);
} else {
lqw.eq(Model::getUid, request.getUid()).isNull(Model::getSpaceId);
}
Model exist = this.getOne(lqw);
if (exist != null) {
throw new BusinessException(ResponseEnum.MODEL_NAME_EXISTED);
}
model = new Model();
model.setUid(request.getUid());
model.setDomain(request.getDomain());
model.setCreateTime(new Date());
} else {
model =
this.getOne(
new LambdaQueryWrapper<Model>()
.eq(Model::getId, request.getId())
.eq(Model::getUid, request.getUid())
.eq(Model::getIsDeleted, 0));
if (model == null) {
throw new BusinessException(ResponseEnum.MODEL_NOT_EXIST);
}
// Handle workflow cleanup triggered by config deletion
List<Config> existConfigs =View on GitHub (pinned to 5e758547a8)