alibaba/spring-ai-alibaba · error · BizException

AppNotFound

AppNotFound

Error message

App can not be found.

What it means

BizException with code AppNotFound thrown by AppServiceImpl.updateApp when getAppById(workspaceId, application.getAppId()) returns null, meaning the app id does not exist in the caller's workspace. Updates are workspace-scoped, so an id from another workspace also yields this error.

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:159

		}
		catch (Exception e) {
			throw new BizException(ErrorCode.CREATE_APP_ERROR.toError(), e);
		}
	}

	/**
	 * Updates an existing application. Creates new version if application is published
	 * @param application Updated application details
	 */
	@Override
	@Transactional(rollbackFor = Exception.class)
	public void updateApp(Application application) {
		try {
			RequestContext context = RequestContextHolder.getRequestContext();

			AppEntity entity = getAppById(context.getWorkspaceId(), application.getAppId());
			if (entity == null) {
				throw new BizException(ErrorCode.APP_NOT_FOUND.toError());
			}

			// check if app name exists
			AppEntity appEntity = getAppByName(context.getWorkspaceId(), application.getName());
			if (appEntity != null && !appEntity.getId().equals(entity.getId())) {
				throw new BizException(ErrorCode.APP_NAME_EXISTS.toError());
			}

			// update app
			AppStatus status = entity.getStatus();

			// add new version only if app status is published
			if (entity.getStatus() == AppStatus.PUBLISHED) {
				status = AppStatus.PUBLISHED_EDITING;
				// copy and create new version
				AppVersionEntity versionEntity = entity.getPublishedVersion();
				AppVersionEntity newVersion = BeanCopierUtils.copy(versionEntity, AppVersionEntity.class);
				newVersion.setId(null);

View on GitHub (pinned to f82da0b50f)

Solutions

  1. Verify the appId exists in the current workspace (list apps) before updating.
  2. Confirm RequestContext workspaceId matches the workspace that owns the app.
  3. Catch AppNotFound and recreate the app or abort the update workflow with a clear message.

Example fix

// before
appService.updateApp(application);
// after
Application existing = appService.getApp(application.getAppId());
if (existing != null) {
    appService.updateApp(application);
}
Defensive patterns

Strategy: validation

Validate before calling

Application app = appService.getApp(application.getAppId());
if (app == null) { throw new IllegalStateException("app " + application.getAppId() + " not in workspace"); }

Try / catch

try { appService.updateApp(application); } catch (BizException e) { if ("AppNotFound".equals(e.getCode())) { /* recreate or abort */ } else throw e; }

Prevention

When it happens

Trigger: Calling updateApp with an appId that was deleted, mistyped, or created in a different workspace; stale references cached client-side.

Common situations: Deploy pipelines referencing apps removed from the workspace; copying app ids across environments; race with a concurrent delete.

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/d9dbde63e8285d62. Report an issue: GitHub.