{"record":{"id":"41d00ba953c19d48","repo":"iflytek/astron-agent","slug":"data-not-found-responseenum","errorCode":"DATA_NOT_FOUND","errorMessage":"ResponseEnum.DATA_NOT_FOUND","messagePattern":"ResponseEnum\\.DATA_NOT_FOUND","errorType":"error_code","errorClass":"BusinessException","httpStatus":null,"severity":"error","filePath":"console/backend/hub/src/main/java/com/iflytek/astron/console/hub/service/agentdebug/impl/AgentDebugServiceImpl.java","lineNumber":162,"sourceCode":"        sessionMapper.update(update, updateWrapper);\n    }\n\n    private void validateUser(String uid) {\n        if (StringUtils.isBlank(uid)) {\n            throw new BusinessException(ResponseEnum.UNAUTHORIZED);\n        }\n    }\n\n    private void checkBotPermission(String uid, Long spaceId, Integer botId) {\n        if (botId == null || chatBotBaseMapper.checkBotPermission(botId, uid, spaceId) <= 0) {\n            throw new BusinessException(ResponseEnum.INSUFFICIENT_PERMISSIONS);\n        }\n    }\n\n    private AgentDebugSession findAccessibleSession(String uid, Long spaceId, String sessionId) {\n        AgentDebugSession session = findSession(uid, sessionId);\n        if (!isSameSpace(session.getSpaceId(), spaceId)) {\n            throw new BusinessException(ResponseEnum.DATA_NOT_FOUND);\n        }\n        checkBotPermission(uid, spaceId, session.getBotId());\n        return session;\n    }\n\n    private boolean isSameSpace(Long sessionSpaceId, Long currentSpaceId) {\n        if (sessionSpaceId == null || currentSpaceId == null) {\n            return sessionSpaceId == null && currentSpaceId == null;\n        }\n        return sessionSpaceId.equals(currentSpaceId);\n    }\n\n    private void addSpaceCondition(LambdaQueryWrapper<AgentDebugSession> queryWrapper, Long spaceId) {\n        if (spaceId == null) {\n            queryWrapper.isNull(AgentDebugSession::getSpaceId);\n        } else {\n            queryWrapper.eq(AgentDebugSession::getSpaceId, spaceId);\n        }","sourceCodeStart":144,"sourceCodeEnd":180,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/hub/src/main/java/com/iflytek/astron/console/hub/service/agentdebug/impl/AgentDebugServiceImpl.java#L144-L180","documentation":"DATA_NOT_FOUND thrown by findAccessibleSession when the debug session belongs to a different space than the request's spaceId. Sessions are hidden (not forbidden) across spaces, so the mismatch surfaces as not-found.","triggerScenarios":"Calling getMessages or update on a sessionId whose AgentDebugSession.spaceId differs from the current spaceId — e.g. stale client cache or cross-space lookup.","commonSituations":"User switched space while a debug session from the old space is open in the UI; bookmarked session id from another space; data migrated between spaces.","solutions":["Refresh the session list in the current space and use a valid sessionId","Ensure the client sends the same spaceId under which the session was created","Recreate the debug session if it belongs to the old space","Verify UI switches/clears debug sessions when the space changes"],"exampleFix":"// before\ngetMessages(sessionId, oldSpaceId);\n// after\nconst sessions = await listSessions(currentSpaceId);\nif (sessions.some(s => s.id === sessionId)) getMessages(sessionId, currentSpaceId);","handlingStrategy":"try-catch","validationCode":"const exists = (await listSessions(currentSpaceId)).some(s => s.id === sessionId); if (!exists) recreateSession();","typeGuard":null,"tryCatchPattern":"try { await getMessages(sessionId, spaceId); } catch (e) { if (e.code === 'DATA_NOT_FOUND') resetDebugSession(); }","preventionTips":["Clear open debug sessions on space switch","Store sessionId together with its spaceId","Treat cross-space ids as not-found by design"],"tags":["not-found","session","space-mismatch"],"backgroundTag":"record-not-found","analyzedSha":"5e758547a83371a5a4b29dadf4ac03e8dd527635","analyzedAt":"2026-09-12T08:03:51.356Z","contentChangedAt":"2026-09-12T08:03:51.356Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}