halo-dev/halo · warning · ServerWebInputException
Required url is missing.
Error message
Required url is missing.
What it means
UploadFromUrlRequest is a record whose compact constructor validates required fields. It throws ServerWebInputException (HTTP 400) 'Required url is missing.' when the url component is null. The url field is annotated @Schema(requiredMode = REQUIRED), so the guard enforces that contract at construction time (i.e. when Spring binds the request body).
Source
Thrown at application/src/main/java/run/halo/app/core/attachment/endpoint/AttachmentEndpoint.java:138
/**
* Request payload for creating an attachment from a remote URL.
*
* @param url remote file URL to transfer into storage
* @param policyName storage policy {@code metadata.name}
* @param groupName attachment group {@code metadata.name}
* @param filename custom file name
*/
public record UploadFromUrlRequest(
@Schema(requiredMode = REQUIRED) URL url,
@Schema(requiredMode = REQUIRED) String policyName,
String groupName,
String filename) {
public UploadFromUrlRequest {
if (Objects.isNull(url)) {
throw new ServerWebInputException("Required url is missing.");
}
if (!StringUtils.hasText(policyName)) {
throw new ServerWebInputException("Policy name must not be blank");
}
}
}
/** Multipart payload for uploading an attachment. */
@Schema(types = "object")
public interface IUploadRequest {
/** Attachment file. */
@Schema(requiredMode = REQUIRED)
FilePart getFile();
/** Storage policy {@code metadata.name}. */
@Schema(requiredMode = REQUIRED)View on GitHub (pinned to d2f5165f9c)
Solutions
- Include a non-null url in the JSON body of the upload-from-url request.
- Disable the submit control on the client until a URL is entered.
- If invoking the endpoint programmatically, assert url != null before serializing the body.
Example fix
// before
{ "policyName": "default" } // 400: url missing
// after
{ "url": "https://example.com/file.png", "policyName": "default" } Defensive patterns
Strategy: validation
Validate before calling
if (url == null) {
return Mono.error(new ServerWebInputException("Required url is missing."));
}
// build UploadFromUrlRequest(url, policyName, groupName, filename) Type guard
static boolean hasUrl(URL url) { return url != null; } Prevention
- Make the url field required in the UI form and disable submit until filled.
- When constructing the body programmatically, assert url != null first.
- Validate that the string parses to a real URL before sending.
When it happens
Trigger: POST to the upload-from-url attachment endpoint with a JSON body that omits "url", sends url:null, or sends a value that cannot be bound to java.net.URL (which may fail earlier in binding).
Common situations: Client form bug that doesn't send the url field; a UI that lets the user submit before entering a URL; integration code constructing the body from optional fields.
Related errors
- Policy name must not be blank
- Invalid part of policyName
- urls must not be empty.
- Invalid part of file
- Required url is missing.
AI-assisted analysis of halo-dev/halo@d2f5165f9c (2026-08-14).
Data as JSON: /api/errors/40b7054d508d3852.
Report an issue: GitHub.