{"record":{"id":"6e65ca40e9ffc22e","repo":"iflytek/astron-agent","slug":"app-tenant-not-found-error","errorCode":"APP_TENANT_NOT_FOUND_ERROR","errorMessage":"source_id not found","messagePattern":"source_id not found","errorType":"error_code","errorClass":"CustomException","httpStatus":null,"severity":"error","filePath":"core/workflow/service/app_service.py","lineNumber":181,"sourceCode":"    :param app_id: The application ID to retrieve\n    :param session: Database session for queries and transactions\n    :param span: Tracing span for logging and monitoring\n    :return: App object containing application information\n    :raises CustomException: If application cannot be found or created\n    \"\"\"\n    # First, try to get from cache\n    app_info = get_app_by_app_id(app_id)\n    if not app_info:\n        # If not in cache, query the database\n        app_info = session.query(App).filter_by(alias_id=app_id).first()\n        if not app_info:\n            # If not in database, fetch from external API\n            await span.add_info_event_async(\n                \"Fetching application source information from management platform\"\n            )\n            source_id = await get_app_source_id(app_id, span)\n            if not source_id:\n                raise CustomException(\n                    CodeEnum.APP_TENANT_NOT_FOUND_ERROR,\n                    err_msg=\"source_id not found\",\n                )\n\n            # Find the corresponding app source in database\n            app_source = session.query(AppSource).filter_by(source_id=source_id).first()\n            if not app_source:\n                raise CustomException(\n                    CodeEnum.APP_TENANT_NOT_FOUND_ERROR,\n                    err_msg=\"app_source not found\",\n                )\n\n            # Get detailed application information from external API\n            name, desc, api_key, api_secret = await get_app_source_detail(app_id, span)\n\n            # Create new App record with fetched information\n            app_info = App(\n                name=name,","sourceCodeStart":163,"sourceCodeEnd":199,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/core/workflow/service/app_service.py#L163-L199","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Verify the app_id exists on the management platform (check via platform UI or API)","Confirm the platform API credentials/scope allow fetching this app","Check that get_app_source_id's request is hitting the correct environment URL","Clear any stale caches and retry; if the app was deleted, use a valid app_id"],"exampleFix":"// before\nsource_id = await get_app_source_id('nonexistent-app-id', span)\n// after\n# ensure app_id is a registered app on the management platform\nsource_id = await get_app_source_id('known-valid-app-id', span)","handlingStrategy":"validation","validationCode":"# before calling get_info, confirm the app exists on the management platform\nsource = await platform_api.get_app(app_id)\nif not source or not source.get('source_id'):\n    raise ValueError(f'app {app_id} is not registered on the management platform')","typeGuard":null,"tryCatchPattern":"try:\n    app_info = await app_service.get_info(app_id, session, span)\nexcept CustomException as e:\n    if e.err_code == CodeEnum.APP_TENANT_NOT_FOUND_ERROR:\n        return error_response(404, f'App {app_id} not found on management platform')\n    raise","preventionTips":["Validate app_id against the platform registry before use","Keep environments separated — never reuse test app_ids in prod","Alert on platform API calls that return empty source_id","Refresh app registrations after platform-side deletions"],"tags":["app-tenant","not-found","management-platform"],"backgroundTag":"resource-not-found","analyzedSha":"5e758547a83371a5a4b29dadf4ac03e8dd527635","analyzedAt":"2026-09-12T08:03:51.356Z","contentChangedAt":"2026-09-12T08:03:51.356Z","schemaVersion":2},"datasetVersion":"2026-09-19T12:17:13.211Z"}