halo-dev/halo · error · ServerWebInputException
Required url is missing.
Error message
Required url is missing.
What it means
Thrown as a ServerWebInputException (HTTP 400) from the UploadFromUrlRequest compact constructor (user-center attachment endpoint) when the 'url' field is null. The record's URL field is declared required; the compact constructor enforces non-null because Spring may bind an absent body to a null url rather than rejecting binding.
Source
Thrown at application/src/main/java/run/halo/app/core/endpoint/uc/AttachmentUcEndpoint.java:315
@Override
public GroupVersion groupVersion() {
return GroupVersion.parseAPIVersion("uc.api.storage.halo.run/v1alpha1");
}
/**
* User-center request payload for uploading from a URL.
*
* @param url remote file URL to transfer into user-center storage
* @param filename custom file name
*/
@Schema(name = "UcUploadFromUrlRequest")
public record UploadFromUrlRequest(
@Schema(requiredMode = REQUIRED) URL url, String filename) {
public UploadFromUrlRequest {
if (Objects.isNull(url)) {
throw new ServerWebInputException("Required url is missing.");
}
}
}
/**
* Multipart payload for uploading a post attachment.
*
* @param file attachment data
* @param postName post {@code metadata.name}
* @param singlePageName single page {@code metadata.name}
*/
@Schema(types = "object")
public record PostAttachmentRequest(
@Schema(requiredMode = REQUIRED) FilePart file,
@Schema(requiredMode = NOT_REQUIRED) String postName,
@Schema(requiredMode = NOT_REQUIRED) String singlePageName) {View on GitHub (pinned to d2f5165f9c)
Solutions
- Provide a non-null 'url' field in the request body, e.g. {"url":"https://example.com/img.png","filename":"img.png"}.
- Add client-side required-field validation on the URL input before submit.
- Ensure the URL parses as java.net.URL (scheme + host present).
Example fix
// before: {}
// after: { "url": "https://example.com/photo.png", "filename": "photo.png" } Defensive patterns
Strategy: validation
Validate before calling
// require a non-null, parseable URL before upload-from-URL
if (url == null || url.isBlank()) {
showUserError("URL is required");
return;
}
try { new java.net.URL(url); } catch (Exception e) {
showUserError("Enter a valid URL"); return;
} Prevention
- Make the URL field required in the upload-from-URL UI.
- Validate scheme+host presence so java.net.URL can parse it.
When it happens
Trigger: POST to the user-center upload-from-URL endpoint (AttachmentUcEndpoint) with a JSON body that omits 'url', sends url:null, or sends an empty body. The record constructor runs and Objects.isNull(url) is true.
Common situations: Frontend submitted the form before entering a URL; client serialized the field with the wrong key; paste left the field empty; API test posted {} intentionally.
Related errors
- Required url is missing.
- Policy name must not be blank
- Invalid part of policyName
- Invalid type of parameter 'file'.
- urls must not be empty.
AI-assisted analysis of halo-dev/halo@d2f5165f9c (2026-08-14).
Data as JSON: /api/errors/dbd04aafec095c7e.
Report an issue: GitHub.