iflytek/astron-agent · error · BusinessException

INVITE_NO_CORRESPONDING_USERS_FOUND

INVITE_NO_CORRESPONDING_USERS_FOUND

Error message

INVITE_NO_CORRESPONDING_USERS_FOUND

What it means

DataPermissionCheckTool.getThreadLocalUidNoNull() reads the current user id from UserInfoManagerHandler (a ThreadLocal populated by the auth filter/interceptor) and throws BusinessException(INVITE_NO_CORRESPONDING_USERS_FOUND) when it is null. It is the mandatory uid source for every ownership check in this tool (uid, checkBotBelong, checkEvalSceneBelong, checkDbUpdateBelong, noPermission, etc.), so any request that reaches permission checks without an authenticated user context fails with this error. Despite the enum's invite-themed name, here it really means 'no user identity in ThreadLocal'.

Solutions

  1. Ensure the calling path is an authenticated request that passes the auth interceptor so UserInfoManagerHandler receives the uid; check the request carries valid login credentials/token.
  2. If running in async/scheduled/consumer code, explicitly set the ThreadLocal (UserInfoManagerHandler) at task start with the propagated uid and clear it in a finally block.
  3. Propagate user identity across threads: capture uid before submitting the async task and restore it inside the task, or use a TaskDecorator.
  4. In tests, set the ThreadLocal uid in setup (@BeforeEach) and remove it in teardown before invoking permission checks.

Example fix

// before
executor.submit(() -> dataPermissionCheckTool.checkBotBelong(bot)); // uid ThreadLocal absent in worker thread
// after
String uid = UserInfoManagerHandler.getUserId();
executor.submit(() -> {
    UserInfoManagerHandler.setUserId(uid);
    try {
        dataPermissionCheckTool.checkBotBelong(bot);
    } finally {
        UserInfoManagerHandler.clear();
    }
});
Defensive patterns

Strategy: type-guard

Validate before calling

String uid = UserInfoManagerHandler.getUserId();
if (uid == null) {
    throw new IllegalStateException("no user context: ensure request passes auth interceptor or set ThreadLocal in async task");
}

Type guard

public static boolean hasUserContext() {
    return UserInfoManagerHandler.getUserId() != null;
}

Try / catch

try {
    dataPermissionCheckTool.checkBotBelong(bot);
} catch (BusinessException e) {
    if (ResponseEnum.INVITE_NO_CORRESPONDING_USERS_FOUND.equals(e.getEnum())) {
        throw new BusinessException(ResponseEnum.INVITE_NO_CORRESPONDING_USERS_FOUND, "user session missing — re-authenticate");
    }
    throw e;
}

Prevention

When it happens

Trigger: Calling any DataPermissionCheckTool check outside of an authenticated HTTP request thread: async/@Async tasks, Kafka consumers, scheduled jobs, internal service-to-service calls that bypass the login interceptor, WebSocket/daemon threads, or tests that don't set UserInfoManagerHandler; also requests where the auth filter skipped setting the uid (unauthenticated/anonymous or expired session not rejected earlier).

Common situations: Moving a service method from a controller to an async executor or @Scheduled task and suddenly hitting this error; calling console services via internal RPC where the auth header isn't propagated; writing unit/integration tests for bot/repo/tool permission checks without stubbing the ThreadLocal.

Related errors


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

Appendix: source

Thrown at console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/tool/DataPermissionCheckTool.java:83

    private final BizConfig bizConfig;
    private final RepoMapper repoMapper;
    private final SparkBotMapper sparkBotMapper;
    private final WorkflowMapper workflowMapper;
    private final DbInfoMapper dbInfoMapper;
    private final DbTableMapper dbTableMapper;
    private final UserLangChainInfoMapper userLangChainInfoDao;
    private final BotMarketDataService botMarketDataService;

    /**
     * Get the current thread's uid, throw business exception if empty.
     *
     * @return the current user ID
     * @throws BusinessException if no user ID found in thread local
     */
    public String getThreadLocalUidNoNull() {
        String uid = UserInfoManagerHandler.getUserId();
        if (uid == null) {
            throw new BusinessException(ResponseEnum.INVITE_NO_CORRESPONDING_USERS_FOUND);
        }
        return uid;
    }

    /**
     * Check if currently in space context.
     *
     * @return true if in space context, false otherwise
     */
    private boolean inSpace() {
        return SpaceInfoUtil.getSpaceId() != null;
    }

    /**
     * Get the current SpaceId (may be null).
     *
     * @return current space ID or null
     */

View on GitHub (pinned to 5e758547a8)