{"record":{"id":"8753ac398ef00629","repo":"iflytek/astron-agent","slug":"repo-file-embedding-failed","errorCode":"REPO_FILE_EMBEDDING_FAILED","errorMessage":"REPO_FILE_EMBEDDING_FAILED","messagePattern":"REPO_FILE_EMBEDDING_FAILED","errorType":"error_code","errorClass":"BusinessException","httpStatus":null,"severity":"error","filePath":"console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/repo/FileInfoV2Service.java","lineNumber":1223,"sourceCode":"                    throw new BusinessException(ResponseEnum.REPO_FILE_EMBEDDING_FAILED);\n                } else {\n                    // Call document binding\n                    JSONObject bindParams = new JSONObject();\n                    bindParams.put(\"datasetId\", sliceFileVO.getRepoId());\n                    bindParams.put(\"files\", sliceFileVO.getSparkFiles());\n                    HashMap<String, String> bindHeader = new HashMap<>();\n                    String authorization = request.getHeader(\"Authorization\");\n                    if (StringUtils.isNotBlank(authorization)) {\n                        bindHeader.put(\"Authorization\", authorization);\n                    }\n                    String bindRsp = OkHttpUtil.post(apiUrl.getXinghuoDatasetFileUrl(), bindHeader, bindParams.toJSONString());\n                    JSONObject bindObject = JSONObject.parseObject(bindRsp);\n                    if (bindObject.getIntValue(\"code\") != 0) {\n                        throw new BusinessException(ResponseEnum.REPO_FILE_EMBEDDING_FAILED);\n                    }\n                }\n            } catch (Exception ex) {\n                throw new BusinessException(ResponseEnum.REPO_FILE_EMBEDDING_FAILED);\n            }\n        } else {\n            List<Long> fileIds = sliceFileVO.getFileIds()\n                    .stream()\n                    .map(Long::valueOf) // Convert String to Long\n                    .collect(Collectors.toList());\n            if (!CollectionUtils.isEmpty(fileIds)) {\n                ExecutorService executorService = Executors.newFixedThreadPool(fileIds.size());\n                for (Long fileId : fileIds) {\n                    FileInfoV2 fileInfo = this.getById(fileId);\n                    if (fileInfo == null) {\n                        log.warn(\"embeddingBack skip: file not found, id={}\", fileId);\n                        continue;\n                    }\n                    if (sliceFileVO.getIsBackTask() == null) {\n                        dataPermissionCheckTool.checkFileBelong(fileInfo);\n                    }\n","sourceCodeStart":1205,"sourceCodeEnd":1241,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/repo/FileInfoV2Service.java#L1205-L1241","documentation":"FileInfoV2Service throws REPO_FILE_EMBEDDING_FAILED when the remote RAG embedding binding call fails: either the HTTP response's JSON code field is non-zero (bindObject.getIntValue(\"code\") != 0) or any exception occurs during the bind/embedding request (parse errors, IO errors, timeouts), which is caught and rethrown as this BusinessException. It signals that the file could not be embedded/vectorized by the downstream RAG service.","triggerScenarios":"Calling the retry/embedding path in FileInfoV2Service where the bind endpoint (OkHttp call) returns a JSON body with code != 0, or the request itself throws (connection refused, timeout, malformed JSON) inside the try block around the bindRsp handling.","commonSituations":"RAG/embedding service is down or unreachable in the environment; the embedding service rejects the file (unsupported type, size limit); auth token/space header missing so the upstream returns an error code; response format changed upstream so parseObject throws.","solutions":["Check the RAG embedding service health and logs for the actual upstream error code returned in the bind response body.","Retry the operation once the embedding service is reachable; transient network failures are converted into this same error.","Validate the file is supported for embedding (format, size) before retrying.","Confirm auth headers and spaceId are correctly forwarded to the embed/bind HTTP call (OkHttpUtil.post with header)."],"exampleFix":"// before\ntry {\n    String bindRsp = OkHttpUtil.post(bindUrl, header, params.toJSONString());\n    JSONObject bindObject = JSONObject.parseObject(bindRsp);\n    if (bindObject.getIntValue(\"code\") != 0) {\n        throw new BusinessException(ResponseEnum.REPO_FILE_EMBEDDING_FAILED);\n    }\n} catch (BusinessException be) {\n    throw be;\n} catch (Exception ex) {\n    log.error(\"embedding bind failed\", ex);\n    throw new BusinessException(ResponseEnum.REPO_FILE_EMBEDDING_FAILED);\n}\n// after\nString bindRsp = OkHttpUtil.post(bindUrl, header, params.toJSONString());\nif (bindRsp == null || bindRsp.isEmpty()) {\n    throw new BusinessException(ResponseEnum.REPO_FILE_EMBEDDING_FAILED, \"empty bind response\");\n}\nJSONObject bindObject = JSONObject.parseObject(bindRsp);\nif (bindObject.getIntValue(\"code\") != 0) {\n    log.error(\"embed bind failed, upstream code={}, msg={}\", bindObject.getIntValue(\"code\"), bindObject.getString(\"message\"));\n    throw new BusinessException(ResponseEnum.REPO_FILE_EMBEDDING_FAILED);\n}","handlingStrategy":"retry","validationCode":"// preflight: embedding service reachable and file embeddable\nif (!ragHealthCheck()) throw new IllegalStateException(\"embedding service unavailable\");\nif (file.getSize() > MAX_EMBED_SIZE) throw new IllegalStateException(\"file too large to embed\");","typeGuard":"boolean isSuccessfulBindResponse(String body) {\n    if (body == null || body.isEmpty()) return false;\n    try { return JSONObject.parseObject(body).getIntValue(\"code\") == 0; }\n    catch (Exception e) { return false; }\n}","tryCatchPattern":"try {\n    fileInfoV2Service.retryEmbedding(vo, request);\n} catch (BusinessException e) {\n    log.error(\"embedding failed for files {}\", vo.getFileIds(), e);\n    // mark files as EMBED_FAILED and surface upstream message to user; retry with backoff\n}","preventionTips":["Monitor RAG/embedding service health; alert before users hit retry.","Forward auth/space headers consistently to downstream embed calls.","Validate file size/format against embedding service limits before submission.","Log the upstream response body to make this error diagnosable."],"tags":["java","spring-boot","embedding","http","rag"],"backgroundTag":"upstream-api-error","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"}