alibaba/spring-ai-alibaba · error · BizException

AppVersionNotFound

AppVersionNotFound

Error message

App version can not be found.

What it means

BizException with code AppVersionNotFound thrown by AppServiceImpl.publishApp when the app exists but has no version entity to publish (appVersionMapper.selectOne returns null after querying for the latest non-DELETED version). The library refuses to publish an app that has no publishable version/config snapshot.

Source

Thrown at spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-core/src/main/java/com/alibaba/cloud/ai/studio/core/base/service/impl/AppServiceImpl.java:339

	 * @param appId ID of the application to publish
	 */
	@Override
	public void publishApp(String appId) {
		RequestContext context = RequestContextHolder.getRequestContext();
		AppEntity entity = getAppById(context.getWorkspaceId(), appId);
		if (entity == null) {
			throw new BizException(ErrorCode.APP_NOT_FOUND.toError());
		}

		LambdaQueryWrapper<AppVersionEntity> queryWrapper = new LambdaQueryWrapper<>();
		queryWrapper.eq(AppVersionEntity::getAppId, appId)
			.eq(AppVersionEntity::getWorkspaceId, context.getWorkspaceId())
			.ne(AppVersionEntity::getStatus, AppStatus.DELETED.getStatus())
			.orderByDesc(AppVersionEntity::getId)
			.last("limit 1");
		AppVersionEntity versionEntity = appVersionMapper.selectOne(queryWrapper);
		if (versionEntity == null) {
			throw new BizException(ErrorCode.APP_VERSION_NOT_FOUND.toError());
		}

		if (entity.getType() == AppType.BASIC) {
			AgentConfig config = JsonUtils.fromJson(versionEntity.getConfig(), AgentConfig.class);
			if (StringUtils.isBlank(config.getModelProvider())) {
				throw new BizException(ErrorCode.MISSING_PARAMS.toError("model_provider"));
			}

			if (StringUtils.isBlank(config.getModel())) {
				throw new BizException(ErrorCode.MISSING_PARAMS.toError("model"));
			}
		}

		versionEntity.setStatus(AppStatus.PUBLISHED);
		versionEntity.setGmtModified(new Date());
		versionEntity.setModifier(context.getAccountId());
		appVersionMapper.updateById(versionEntity);

View on GitHub (pinned to f82da0b50f)

Solutions

  1. Save at least one app version/config (e.g. updateApp) before calling publishApp.
  2. Check the app_version table for rows with the appId that are not status=DELETED.
  3. Publish only after an edit/save workflow has produced a version, not immediately after creation.

Example fix

// before
appService.createApp(application);
appService.publishApp(appId); // no version yet
// after
String appId = appService.createApp(application);
application.setAppId(appId);
appService.updateApp(application); // persists a version/config
appService.publishApp(appId);
Defensive patterns

Strategy: validation

Validate before calling

// ensure a saved version exists before publishing
appService.updateApp(applicationWithConfig); // persists version data
appService.publishApp(application.getAppId());

Try / catch

try { appService.publishApp(appId); } catch (BizException e) { if ("AppVersionNotFound".equals(e.getCode())) { /* save a version then retry publish */ } else throw e; }

Prevention

When it happens

Trigger: Publishing a newly created app whose first version was never saved or was marked DELETED; all versions filtered out by the ne(status, DELETED) predicate; draft-only apps with no saved version rows.

Common situations: Apps created programmatically without saving a version/config; cleanup jobs soft-deleting all versions; publishing immediately after creation before any edit is saved.

Understand the failure class

Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.

Related errors


AI-assisted analysis of alibaba/spring-ai-alibaba@f82da0b50f (2026-09-09). Data as JSON: /api/errors/00feaa8878c11cb4. Report an issue: GitHub.