iflytek/astron-agent · error · BusinessException

FILE_EMPTY

FILE_EMPTY

Error message

FILE_EMPTY

What it means

BusinessException(ResponseEnum.FILE_EMPTY) thrown at the top of AudioValidator.validateAudioFile when the uploaded MultipartFile is null or isEmpty(). The validator refuses to process any upload that carries no bytes, before format/size/audio-property checks run. It is the first gate of the audio upload validation chain.

Solutions

  1. Select a real, non-empty audio file in the client before submitting the request.
  2. Check the multipart field name matches the controller parameter (e.g. "file") so Spring binds the part.
  3. Verify curl/HTTP client flags: use -F "file=@recording.wav" (not -d) so the body is sent as multipart with content.
  4. Server-side: return the FILE_EMPTY message to the client so the UI can prompt for a valid file instead of retrying blindly.

Example fix

// before
curl -X POST http://host/audio -d "file=@empty.wav"
// after
curl -X POST http://host/audio -F "file=@recording.wav"
Defensive patterns

Strategy: validation

Validate before calling

if (file == null || file.isEmpty() || file.getSize() == 0) { alert('Please select a non-empty audio file'); return; }

Type guard

boolean hasFile(MultipartFile f) { return f != null && !f.isEmpty(); }

Try / catch

try { AudioValidator.validateAudioFile(file); }
catch (BusinessException e) { if (ResponseEnum.FILE_EMPTY.equals(e.getResponseEnum())) { /* 400: prompt user to pick a file */ } else { throw e; } }

Prevention

When it happens

Trigger: POSTing a multipart request to an audio upload endpoint with an empty file part, a zero-byte file, omitting the file field entirely (file == null), or a client that sends the part name but no content.

Common situations: Frontend forms submitted without the user picking a file; curl commands using -F "file=@empty.wav" with a 0-byte file; HTML form field name mismatch causing Spring to bind null; interrupted uploads that produce empty parts.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


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

Appendix: source

Thrown at console/backend/commons/src/main/java/com/iflytek/astron/console/commons/util/AudioValidator.java:48

    private static final int REQUIRED_CHANNELS = 1;
    // 24kHz
    private static final float MIN_SAMPLE_RATE = 24000.0f;
    // 16bit
    private static final int REQUIRED_SAMPLE_SIZE = 16;
    // 40 seconds
    private static final int MAX_DURATION_SECONDS = 40;
    // 3MB
    private static final long MAX_FILE_SIZE_BYTES = 3 * 1024 * 1024;

    /**
     * Validate audio file
     *
     * @param file uploaded file
     * @throws BusinessException throws business exception when validation fails
     */
    public static void validateAudioFile(MultipartFile file) throws BusinessException {
        if (file == null || file.isEmpty()) {
            throw new BusinessException(ResponseEnum.FILE_EMPTY);
        }

        // 1. Check file format
        validateFileFormat(file);

        // 2. Check file size
        validateFileSize(file);

        // 3. Check audio properties
        validateAudioProperties(file);
    }

    /**
     * Validate file format
     */
    private static void validateFileFormat(MultipartFile file) throws BusinessException {
        String filename = file.getOriginalFilename();
        if (filename == null) {

View on GitHub (pinned to 5e758547a8)