{"record":{"id":"5139f7a572ce6d7e","repo":"conductor-oss/conductor","slug":"error-uploading-file-s-s","errorCode":null,"errorMessage":"error uploading file %s - %s","messagePattern":"error uploading file (.+?) - (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"ai/src/main/java/org/conductoross/conductor/ai/document/HttpDocumentLoader.java","lineNumber":93,"sourceCode":"        }\n    }\n\n    @Override\n    public String upload(\n            Map<String, String> headers, String contentType, byte[] data, String fileURI) {\n        try {\n            if (fileURI == null) {\n                return null;\n            }\n            accessPolicy.validateAccess(fileURI);\n            Input input = new Input();\n            input.getHeaders().putAll(headers);\n            input.setMethod(\"POST\");\n            input.setUri(fileURI);\n            input.setBody(data);\n            HttpResponse response = retryOperation(this::httpCall, 3, input);\n            if (response.isError()) {\n                throw new RuntimeException(\n                        \"error uploading file %s - %s\"\n                                .formatted(response.statusCode, response.reasonPhrase));\n            }\n            return fileURI;\n        } catch (Throwable t) {\n            log.error(t.getMessage(), t);\n            throw new RuntimeException(t);\n        }\n    }\n\n    @Override\n    public List<String> listFiles(String location) {\n        return List.of();\n    }\n\n    @Override\n    public boolean supports(String location) {\n        return location.startsWith(\"http://\") || location.startsWith(\"https://\");","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/conductor-oss/conductor/blob/cf7c3e4a8adfb158be778ab1ec525323c363cd3a/ai/src/main/java/org/conductoross/conductor/ai/document/HttpDocumentLoader.java#L75-L111","documentation":"Thrown by HttpDocumentLoader.upload when the upload HTTP response has a non-2xx status (response.isError()). The message is formatted with statusCode and reasonPhrase (e.g. 'error uploading file 401 - Unauthorized'). It is itself a RuntimeException, but note the outer try/catch then re-wraps it again into a new RuntimeException, so the visible cause chain is double-wrapped. Access policy (validateAccess) runs before the request.","triggerScenarios":"An HTTP POST upload to fileURI returns 4xx/5xx: 401/403 auth/permission failure, 404 wrong endpoint, 413 payload too large, 415 unsupported media type, or a 5xx server error.","commonSituations":"Missing/expired auth header in the upload; wrong content-type; the upload endpoint URL is wrong; the target server rejects the payload size; server-side transient 5xx.","solutions":["Decode the statusCode: 401/403 -> fix the Authorization header/credentials; 404 -> verify fileURI; 413 -> reduce payload or raise server limit; 415 -> set the correct contentType; 5xx -> retry / check target health.","Unwrap the exception (getCause()) to read the original 'error uploading file ...' message, since it is re-wrapped by the outer catch.","Ensure the headers map passed to upload includes any required auth/token.","Confirm the contentType argument matches what the endpoint expects."],"exampleFix":"// before\nloader.upload(Map.of(), \"text/plain\", data, \"https://svc/upload\")\n// after — add auth + correct content type\nloader.upload(Map.of(\"Authorization\", \"Bearer \" + token), \"application/octet-stream\", data, \"https://svc/upload\")","handlingStrategy":"try-catch","validationCode":"// Pre-flight the upload endpoint/auth is out of scope here; instead validate inputs\nif (fileURI == null || fileURI.isBlank()) throw new IllegalArgumentException(\"fileURI required\");\nif (!headers.containsKey(\"Authorization\") && endpointRequiresAuth(fileURI)) {\n    throw new IllegalStateException(\"Upload to \" + fileURI + \" requires an Authorization header\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    loader.upload(headers, contentType, data, fileURI);\n} catch (RuntimeException e) {\n    // unwrap: the inner 'error uploading file <code> - <reason>' may be double-wrapped\n    Throwable root = e.getCause() instanceof RuntimeException rc ? rc : e;\n    log.error(\"Upload failed: {}\", root.getMessage());\n    throw e;\n}","preventionTips":["Always include required auth headers in the upload headers map.","Set the contentType the endpoint expects (e.g. application/octet-stream for binary).","Confirm the upload endpoint URL is correct before relying on it."],"tags":["document-loader","upload","http","okhttp","runtimeexception"],"backgroundTag":null,"analyzedSha":"cf7c3e4a8adfb158be778ab1ec525323c363cd3a","analyzedAt":"2026-08-14T03:33:19.897Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}