iflytek/astron-agent · error · BusinessException

UNAUTHORIZED

UNAUTHORIZED

Error message

ResponseEnum.UNAUTHORIZED

What it means

Thrown in ensureNoUnresolvedImportDependencies when the caller's uid is blank while validating imported workflow dependencies. Resolving which plugins/models/databases the imported flow may use requires the current user's identity; without it the service cannot authorize the check and rejects with UNAUTHORIZED.

Solutions

  1. Ensure the import API is called with a valid authenticated session (Authorization header/token)
  2. Re-login if the token expired and uid resolution became blank
  3. Fix internal callers to propagate the current user context (uid, spaceId)
  4. Check gateway/auth filter config so user identity headers reach the service
Defensive patterns

Strategy: validation

Validate before calling

if (uid == null || uid.isBlank()) { throw new IllegalStateException("must be called with an authenticated user"); }

Try / catch

try { workflowService.importWorkflow(req); } catch (BusinessException e) { if ("UNAUTHORIZED".equals(e.getCode().name())) { /* re-authenticate */ } throw e; }

Prevention

When it happens

Trigger: Importing a workflow when the request context has no authenticated user id (uid blank/null) — e.g. calls outside a logged-in session, missing auth header, or internal calls that dropped the user context.

Common situations: Batch import scripts calling service methods directly without setting the security context; auth token expired so uid resolution returned blank; misconfigured gateway stripping user headers.

Understand the failure class

Related errors


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

Appendix: source

Thrown at console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/workflow/WorkflowService.java:2534

    }

    /** Imported drafts remain editable, but unresolved external dependencies must never execute. */
    void ensureNoUnresolvedImportDependencies(BizWorkflowData workflowData) {
        if (workflowData == null || workflowData.getNodes() == null) {
            return;
        }
        ensureNoUnresolvedImportDependencies(
                workflowData,
                UserInfoManagerHandler.getUserId(),
                SpaceInfoUtil.getSpaceId());
    }

    void ensureNoUnresolvedImportDependencies(BizWorkflowData workflowData, String uid, Long spaceId) {
        if (workflowData == null || workflowData.getNodes() == null) {
            return;
        }
        if (StringUtils.isBlank(uid)) {
            throw new BusinessException(ResponseEnum.UNAUTHORIZED);
        }
        ExecutionScope scope = loadExecutionScope(uid, spaceId);
        ImportDependencyResources resources = loadImportDependencyResources(workflowData, scope);
        boolean unresolved = workflowData.getNodes()
                .stream()
                .anyMatch(node -> hasActiveImportIssue(node, resources)
                        || hasInvalidPluginBinding(node, resources)
                        || hasInvalidResourceBinding(node, resources));
        if (unresolved) {
            throw new BusinessException(ResponseEnum.WORKFLOW_IMPORT_DEPENDENCY_UNRESOLVED);
        }
    }

    /** Load every bound external resource in bounded authoritative batch queries. */
    private ImportDependencyResources loadImportDependencyResources(
            BizWorkflowData workflowData, ExecutionScope scope) {
        Map<String, List<ToolBox>> executableTools = loadExecutableTools(workflowData);
        Set<Long> databaseIds = new LinkedHashSet<>();

View on GitHub (pinned to 5e758547a8)