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

Report invalid @MultipartForm format #26158

Closed
Ratoone opened this issue Jun 15, 2022 · 2 comments · Fixed by #26170
Closed

Report invalid @MultipartForm format #26158

Ratoone opened this issue Jun 15, 2022 · 2 comments · Fixed by #26170
Assignees
Labels
Milestone

Comments

@Ratoone
Copy link

Ratoone commented Jun 15, 2022

Description

In case a multipart/form-data request is handled, for example:

@ApplicationScoped
@Path("/uploads")
public class UploadsResource {
    @POST
    @Consumes(MediaType.MULTIPART_FORM_DATA)
    @Produces(MediaType.APPLICATION_JSON)
    public Response upload(@MultipartForm UploadDto uploadDto) {
        // do sth
    }
}

With a DTO:

@Getter
@NoArgsConstructor
public class UploadDto {
    @FormParam("format")
    @PartType(MediaType.APPLICATION_JSON)
    private List<MyEnum> format;

    @FormParam("file")
    @PartType(MediaType.APPLICATION_OCTET_STREAM)
    private File file;
}

If the format is provided correctly, it works as expected, otherwise it fails silently with a 500 - whether the JSON is wrongly formatted or the elements do not respect the MyEnum values. But in this case I want to be able to notify the user that the request is wrong, returning a custom message - or at least being able to see in the logs why the request failed.

Implementation ideas

No response

@Ratoone Ratoone added the kind/enhancement New feature or request label Jun 15, 2022
@geoand geoand self-assigned this Jun 16, 2022
geoand added a commit to geoand/quarkus that referenced this issue Jun 16, 2022
geoand added a commit to geoand/quarkus that referenced this issue Jun 16, 2022
@geoand
Copy link
Contributor

geoand commented Jun 16, 2022

Thanks for reporting. #26170 takes care of it

geoand added a commit to geoand/quarkus that referenced this issue Jun 17, 2022
geoand added a commit to geoand/quarkus that referenced this issue Jun 17, 2022
@quarkus-bot
Copy link

quarkus-bot bot commented Jun 17, 2022

/cc @FroMage, @geoand, @stuartwdouglas

geoand added a commit that referenced this issue Jun 17, 2022
Improve server side multipart exception handling
@quarkus-bot quarkus-bot bot added this to the 2.11 - main milestone Jun 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants