iflytek/astron-agent · error · BusinessException

RESPONSE_FAILED

RESPONSE_FAILED

Error message

Creating custom categories requires recording creator UID

What it means

ModelCategoryService.saveAll throws this when the request tries to save at least one user-defined (custom) category or scene name but does not carry ownerUid. Custom categories are per-user data, so the platform must record which user created them; without a creator UID the insert would be unattributable, so the service rejects the request up front.

Solutions

  1. Populate req.setOwnerUid(...) with the current authenticated user's UID before calling saveAll
  2. Ensure the controller/interceptor injects the logged-in user's UID into the request DTO (e.g. from the auth context)
  3. If no custom name is intended, clear categoryCustom/sceneCustom (or leave customName blank) so the check does not fire
  4. Add a request-level validation (e.g. @NotNull on ownerUid when customName present) so callers fail fast with a clearer message

Example fix

// before
ModelCategorySaveRequest req = new ModelCategorySaveRequest();
req.setCategoryCustom(CustomItem.of("My Custom Tag"));
modelCategoryService.saveAll(req);
// after
req.setOwnerUid(currentUserId); // from auth context
modelCategoryService.saveAll(req);
Defensive patterns

Strategy: validation

Validate before calling

boolean hasCustom = (req.getCategoryCustom() != null && req.getCategoryCustom().getCustomName() != null && !req.getCategoryCustom().getCustomName().isBlank()) || (req.getSceneCustom() != null && req.getSceneCustom().getCustomName() != null && !req.getSceneCustom().getCustomName().isBlank());
if (hasCustom && req.getOwnerUid() == null) throw new IllegalArgumentException("ownerUid is required when submitting custom categories");

Type guard

boolean isCustomSubmit(ModelCategorySaveRequest req) { return req != null && ((req.getCategoryCustom() != null && hasText(req.getCategoryCustom().getCustomName())) || (req.getSceneCustom() != null && hasText(req.getSceneCustom().getCustomName()))); }

Try / catch

try { modelCategoryService.saveAll(req); } catch (BusinessException e) { if (e.getMessage() != null && e.getMessage().contains("creator UID")) { return 400-uid-required; } throw e; }

Prevention

When it happens

Trigger: Calling saveAll with categoryCustom.customName or sceneCustom.customName set (non-blank) while req.ownerUid is null. Typically happens when a client builds the ModelCategorySaveRequest from an unauthenticated context or forgets to propagate the current user's UID into the request object.

Common situations: Admin/internal tooling calling the category-save API without logging in as a user; a frontend passing the body through without the uid field; service-to-service calls that strip ownerUid; tests constructing the request with only the custom name.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — 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/bee092cd399ff933. Report an issue: GitHub.

Appendix: source

Thrown at console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/model/ModelCategoryService.java:129

        return roots;
    }

    /**
     * Save four types of model configurations (all implemented through category relationships)
     *
     * @param req Input parameter containing systemIds / customNames for each dimension
     */
    @Transactional(rollbackFor = Exception.class)
    public void saveAll(ModelCategoryReq req) {
        if (req == null || req.getModelId() == null) {
            return;
        }
        final Long modelId = req.getModelId();
        boolean hasAnyCustom =
                (req.getCategoryCustom() != null && StringUtils.isNotBlank(req.getCategoryCustom().getCustomName())) ||
                        (req.getSceneCustom() != null && StringUtils.isNotBlank(req.getSceneCustom().getCustomName()));
        if (hasAnyCustom && req.getOwnerUid() == null) {
            throw new BusinessException(ResponseEnum.RESPONSE_FAILED, "Creating custom categories requires recording creator UID");
        }

        // ---------- 1) Preprocess official IDs (deduplicate, remove empty) ----------
        List<Long> catSys = safeDistinctIds(req.getCategorySystemIds());
        List<Long> sceneSys = safeDistinctIds(req.getSceneSystemIds());

        // ---------- 2) Preprocess custom items (trim names; treat blank names as not provided) ----------
        ModelCategoryReq.CustomItem catCustom = normalizeCustom(req.getCategoryCustom());
        ModelCategoryReq.CustomItem sceneCustom = normalizeCustom(req.getSceneCustom());

        // ---------- 3) Custom item parent-child dimension & status validation ----------
        // Rule: pid must exist in model_category, and p.is_delete=0, and p.key matches target dimension key
        if (catCustom != null) {
            assertParentOk(catCustom.getPid(), "modelCategory");
        }
        if (sceneCustom != null) {
            assertParentOk(sceneCustom.getPid(), "modelScenario");
        }

View on GitHub (pinned to 5e758547a8)