{"record":{"id":"7209c61d7a279dec","repo":"iflytek/astron-agent","slug":"param-error","errorCode":"PARAM_ERROR","errorMessage":"PARAM_ERROR","messagePattern":"PARAM_ERROR","errorType":"validation","errorClass":"BusinessException","httpStatus":null,"severity":"error","filePath":"console/backend/commons/src/main/java/com/iflytek/astron/console/commons/util/AudioValidator.java","lineNumber":180,"sourceCode":"        // 40 seconds of audio is approximately 1.92MB, leaving some margin\n        long estimatedMaxSizeForDuration = (long) (MAX_DURATION_SECONDS * 48000 * 1.5);\n\n        if (fileSize > estimatedMaxSizeForDuration) {\n            log.warn(\"Audio file size {} exceeds expected, may be too long\", fileSize);\n            // Do not throw exception because this is only a rough estimate\n        }\n    }\n\n    /**\n     * Validate basic audio properties (used when audio format cannot be parsed)\n     */\n    private static void validateBasicAudioProperties(MultipartFile file) throws BusinessException {\n        // Basic validation: file size reasonableness check\n        long fileSize = file.getSize();\n\n        // Ensure file is not too small (at least 1KB)\n        if (fileSize < 1024) {\n            throw new BusinessException(ResponseEnum.PARAM_ERROR);\n        }\n\n        log.info(\"Audio file passed basic validation, filename: {}, size: {} bytes\", file.getOriginalFilename(), fileSize);\n    }\n\n    /**\n     * Get file extension\n     */\n    private static String getFileExtension(String filename) {\n        int lastDotIndex = filename.lastIndexOf('.');\n        if (lastDotIndex == -1 || lastDotIndex == filename.length() - 1) {\n            return \"\";\n        }\n        return filename.substring(lastDotIndex + 1);\n    }\n}\n","sourceCodeStart":162,"sourceCodeEnd":197,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/commons/src/main/java/com/iflytek/astron/console/commons/util/AudioValidator.java#L162-L197","documentation":"BusinessException(ResponseEnum.PARAM_ERROR) thrown by validateBasicAudioProperties when the uploaded file is smaller than 1024 bytes (1KB). The validator treats sub-1KB audio as unreasonably small — likely corrupt, truncated, or not real audio — and rejects it as a parameter error even though format and size caps already passed.","triggerScenarios":"Uploading an audio file whose file.getSize() < 1024 bytes — e.g. a truncated download, a near-empty wav header-only file, or a tiny placeholder file — through validateAudioProperties during audio upload.","commonSituations":"Interrupted uploads that only transferred the file header; files truncated by editors or transfer tools; placeholder/zero-ish-byte files renamed to .wav; clients generating audio buffers that never got real samples written.","solutions":["Re-upload the complete original audio file — verify locally it is larger than 1KB.","Check the source file integrity (play it locally) to confirm it is not truncated or corrupt.","Re-export/re-record the audio; ensure the recording actually captured samples.","Compare file sizes before and after transfer (checksum/size) to detect truncation in transit."],"exampleFix":"// before: truncated file slipped through\nconst bytes = fs.readFileSync('truncated.wav'); // 512 bytes\nupload(bytes);\n// after: guard before sending\nif (bytes.length < 1024) throw new Error('audio file too small/truncated');\nupload(bytes);","handlingStrategy":"validation","validationCode":"if (file.size < 1024) { alert('Audio file is too small or truncated'); return; }","typeGuard":"boolean plausiblyRealAudio(MultipartFile f) { return f != null && f.getSize() >= 1024; }","tryCatchPattern":"try { AudioValidator.validateAudioProperties(file); }\ncatch (BusinessException e) { if (ResponseEnum.PARAM_ERROR.equals(e.getResponseEnum())) { /* 400: re-upload a complete file */ } else { throw e; } }","preventionTips":["Check file size >= 1KB client-side before upload.","Verify recordings play locally (not truncated).","Compare sizes/checksums before and after transfer.","Ensure recording pipelines actually write sample data, not just headers."],"tags":["java","audio","validation","file-size"],"backgroundTag":"invalid-argument-value","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"}