iflytek/astron-agent · error · BusinessException

8332

8332

Error message

toolbox.import.file.format.error

What it means

TOOLBOX_IMPORT_FILE_FORMAT_ERROR (code 8332) is thrown when the uploaded import file's extension is neither .yaml/.yml nor .json. The service only supports those two formats and rejects everything else before attempting to parse.

Solutions

  1. Upload a file whose name ends with .json, .yaml, or .yml
  2. Re-export the tool from the platform to get a correctly formatted file
  3. Rename the file to add the proper extension if the content is actually JSON/YAML

Example fix

// before
POST import with file named "mytool.txt"
// after
POST import with file named "mytool.json"
Defensive patterns

Strategy: validation

Validate before calling

String n = file.getOriginalFilename().toLowerCase(); if (!n.endsWith(".json") && !n.endsWith(".yaml") && !n.endsWith(".yml")) { throw new IllegalArgumentException("only .json/.yaml/.yml imports are supported"); }

Type guard

boolean isSupportedImportFile(String name) { if (name == null) return false; String n = name.toLowerCase(); return n.endsWith(".json") || n.endsWith(".yaml") || n.endsWith(".yml"); }

Try / catch

try { toolBoxApi.importTool(file); } catch (BusinessException e) { if (e.getCode() == 8332) { /* tell user to use .json/.yaml/.yml */ } else throw e; }

Prevention

When it happens

Trigger: Importing a file with a different extension (e.g. .txt, .xml, no extension) or no recognizable suffix at all.

Common situations: Users renaming an export without keeping the extension; exporting from another tool in a different format and uploading it directly; OS hiding extensions leading to files like tool.json.txt.

Related errors


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

Appendix: source

Thrown at console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/tool/ToolBoxService.java:2287

            String fileName = file.getOriginalFilename();
            ObjectMapper jsonMapper = new ObjectMapper();
            ObjectMapper yamlMapper = new ObjectMapper(new YAMLFactory());

            if (fileName == null) {
                throw new BusinessException(ResponseEnum.TOOLBOX_IMPORT_FILE_NAME_NULL);
            }

            String lowerName = fileName.toLowerCase();

            ToolBoxExportVo vo;
            if (lowerName.endsWith(".yaml") || lowerName.endsWith(".yml")) {
                // YAML -> ToolBoxExportVo
                vo = yamlMapper.readValue(file.getInputStream(), ToolBoxExportVo.class);
            } else if (lowerName.endsWith(".json")) {
                // JSON -> ToolBoxExportVo
                vo = jsonMapper.readValue(file.getInputStream(), ToolBoxExportVo.class);
            } else {
                throw new BusinessException(ResponseEnum.TOOLBOX_IMPORT_FILE_FORMAT_ERROR);
            }
            return vo;
        } catch (Exception ex) {
            log.error("Import failed", ex);
            if (ex instanceof BusinessException) {
                throw (BusinessException) ex;
            }
            throw new BusinessException(ResponseEnum.TOOLBOX_IMPORT_ERROR);
        }
    }
}

View on GitHub (pinned to 5e758547a8)