iflytek/astron-agent · error · CustomException

APP_TENANT_NOT_FOUND_ERROR

APP_TENANT_NOT_FOUND_ERROR

Error message

source_id not found

What it means

APP_TENANT_NOT_FOUND_ERROR raised in app_service.get_info when get_app_source_id returns no source_id for the given app_id from the external management platform API. It means the app exists as an ID but the platform did not return a source mapping, so no app source can be resolved.

Solutions

  1. Verify the app_id exists on the management platform (check via platform UI or API)
  2. Confirm the platform API credentials/scope allow fetching this app
  3. Check that get_app_source_id's request is hitting the correct environment URL
  4. Clear any stale caches and retry; if the app was deleted, use a valid app_id

Example fix

// before
source_id = await get_app_source_id('nonexistent-app-id', span)
// after
# ensure app_id is a registered app on the management platform
source_id = await get_app_source_id('known-valid-app-id', span)
Defensive patterns

Strategy: validation

Validate before calling

# before calling get_info, confirm the app exists on the management platform
source = await platform_api.get_app(app_id)
if not source or not source.get('source_id'):
    raise ValueError(f'app {app_id} is not registered on the management platform')

Try / catch

try:
    app_info = await app_service.get_info(app_id, session, span)
except CustomException as e:
    if e.err_code == CodeEnum.APP_TENANT_NOT_FOUND_ERROR:
        return error_response(404, f'App {app_id} not found on management platform')
    raise

Prevention

When it happens

Trigger: Calling get_info (directly or via auth_service.handle) with an app_id that the management platform does not recognize, an app that was deleted, or when the platform API call silently returns empty.

Common situations: Stale app_id after the app was removed on the management platform, wrong environment (test app_id used against prod platform), platform API returning empty due to auth scope, typo in app_id.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12). Data as JSON: /api/errors/6e65ca40e9ffc22e. Report an issue: GitHub.

Appendix: source

Thrown at core/workflow/service/app_service.py:181

    :param app_id: The application ID to retrieve
    :param session: Database session for queries and transactions
    :param span: Tracing span for logging and monitoring
    :return: App object containing application information
    :raises CustomException: If application cannot be found or created
    """
    # First, try to get from cache
    app_info = get_app_by_app_id(app_id)
    if not app_info:
        # If not in cache, query the database
        app_info = session.query(App).filter_by(alias_id=app_id).first()
        if not app_info:
            # If not in database, fetch from external API
            await span.add_info_event_async(
                "Fetching application source information from management platform"
            )
            source_id = await get_app_source_id(app_id, span)
            if not source_id:
                raise CustomException(
                    CodeEnum.APP_TENANT_NOT_FOUND_ERROR,
                    err_msg="source_id not found",
                )

            # Find the corresponding app source in database
            app_source = session.query(AppSource).filter_by(source_id=source_id).first()
            if not app_source:
                raise CustomException(
                    CodeEnum.APP_TENANT_NOT_FOUND_ERROR,
                    err_msg="app_source not found",
                )

            # Get detailed application information from external API
            name, desc, api_key, api_secret = await get_app_source_detail(app_id, span)

            # Create new App record with fetched information
            app_info = App(
                name=name,

View on GitHub (pinned to 5e758547a8)