conductor-oss/conductor · error · RuntimeException
error uploading file %s - %s
Error message
error uploading file %s - %s
What it means
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.
Source
Thrown at ai/src/main/java/org/conductoross/conductor/ai/document/HttpDocumentLoader.java:93
}
}
@Override
public String upload(
Map<String, String> headers, String contentType, byte[] data, String fileURI) {
try {
if (fileURI == null) {
return null;
}
accessPolicy.validateAccess(fileURI);
Input input = new Input();
input.getHeaders().putAll(headers);
input.setMethod("POST");
input.setUri(fileURI);
input.setBody(data);
HttpResponse response = retryOperation(this::httpCall, 3, input);
if (response.isError()) {
throw new RuntimeException(
"error uploading file %s - %s"
.formatted(response.statusCode, response.reasonPhrase));
}
return fileURI;
} catch (Throwable t) {
log.error(t.getMessage(), t);
throw new RuntimeException(t);
}
}
@Override
public List<String> listFiles(String location) {
return List.of();
}
@Override
public boolean supports(String location) {
return location.startsWith("http://") || location.startsWith("https://");View on GitHub (pinned to cf7c3e4a8a)
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.
Example fix
// before
loader.upload(Map.of(), "text/plain", data, "https://svc/upload")
// after — add auth + correct content type
loader.upload(Map.of("Authorization", "Bearer " + token), "application/octet-stream", data, "https://svc/upload") Defensive patterns
Strategy: try-catch
Validate before calling
// Pre-flight the upload endpoint/auth is out of scope here; instead validate inputs
if (fileURI == null || fileURI.isBlank()) throw new IllegalArgumentException("fileURI required");
if (!headers.containsKey("Authorization") && endpointRequiresAuth(fileURI)) {
throw new IllegalStateException("Upload to " + fileURI + " requires an Authorization header");
} Try / catch
try {
loader.upload(headers, contentType, data, fileURI);
} catch (RuntimeException e) {
// unwrap: the inner 'error uploading file <code> - <reason>' may be double-wrapped
Throwable root = e.getCause() instanceof RuntimeException rc ? rc : e;
log.error("Upload failed: {}", root.getMessage());
throw e;
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Error making an HTTP call {reasonPhrase}, status: {statusCod
- Failed to read InputStream for upload
- OAuth token request failed: HTTP {code}
- Access denied: path matches blocked prefix '{prefix}'
- Access denied: file name '{fileName}' is blocked
AI-assisted analysis of conductor-oss/conductor@cf7c3e4a8a (2026-08-14).
Data as JSON: /api/errors/5139f7a572ce6d7e.
Report an issue: GitHub.