Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multipart request to create entity and content in one request fail to create entity when file is missing #1904

Closed
NielsCW opened this issue Apr 12, 2024 · 0 comments · Fixed by #1948

Comments

@NielsCW
Copy link
Contributor

NielsCW commented Apr 12, 2024

Describe the bug
If no file is provided in the multipart request to create entity and content, the creation of the self-link fails because the Id property is null.

  • The Id property is null because savedEntity is not yet persisted with repository.save()
  • When providing a file, savedEntity is persisted during setContent()

To Reproduce

@Test
void postMultipartEntityAndContent_noFile_http201() throws Exception {
    mockMvc.perform(multipart(HttpMethod.POST, "/invoices")
                    .param("number", INVOICE_NUMBER)
                    .param("customer", "/customers/" + CUSTOMER_ID))
            .andExpect(status().isCreated());
}

Results in: IllegalArgumentException: Id must be assignable to Serializable: null

Expected behavior
Entity gets created without the content property set

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant