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

feat(website): show a meaningful error if uploaded file is too large #1634

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions backend/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ springdoc.default-consumes-media-type=application/json
springdoc.api-docs.path=/api-docs
springdoc.swagger-ui.operationsSorter=alpha
server.forward-headers-strategy=framework
spring.servlet.multipart.max-file-size=5000MB
spring.servlet.multipart.max-request-size=5000MB
spring.servlet.multipart.max-file-size=200MB
spring.servlet.multipart.max-request-size=200MB


server.compression.enabled=true
Expand Down
9 changes: 9 additions & 0 deletions website/src/components/Submission/DataUploadForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ type DataUploadFormProps = {

const logger = getClientLogger('DataUploadForm');

// This should be the same value as defined in the backend.
const MAX_UPLOAD_SIZE = '800 MB';

const DataUseTerms = ({
dataUseTermsType,
setDataUseTermsType,
Expand Down Expand Up @@ -436,6 +439,12 @@ function handleError(onError: (message: string) => void, action: Action) {
case 400:
onError('Failed to submit sequence entries: ' + error.response.data.detail);
return;
case 413:
onError(
`The uploaded file exceeds the maximum allowed size of ${MAX_UPLOAD_SIZE}. Please compress ` +
'the file or split it into smaller submissions.',
);
return;
case 422:
onError('The submitted file content was invalid: ' + error.response.data.detail);
return;
Expand Down
9 changes: 8 additions & 1 deletion website/src/services/backendApi.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { makeApi, makeEndpoint } from '@zodios/core';
import z from 'zod';

import { authorizationHeader, notAuthorizedError, withOrganismPathSegment } from './commonApiTypes.ts';
import {
authorizationHeader,
notAuthorizedError,
payloadTooLargeError,
withOrganismPathSegment,
} from './commonApiTypes.ts';
import {
accessions,
accessionVersion,
Expand Down Expand Up @@ -37,6 +42,7 @@ const submitEndpoint = makeEndpoint({
{ status: 400, schema: problemDetail },
{ status: 422, schema: problemDetail },
notAuthorizedError,
payloadTooLargeError,
],
});

Expand All @@ -59,6 +65,7 @@ const reviseEndpoint = makeEndpoint({
{ status: 400, schema: problemDetail },
{ status: 422, schema: problemDetail },
notAuthorizedError,
payloadTooLargeError,
],
});

Expand Down
7 changes: 7 additions & 0 deletions website/src/services/commonApiTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,10 @@ export const notAuthorizedError = makeErrors([
])[0];

export const conflictError = { status: 409, schema: problemDetail };

export const payloadTooLargeError = makeErrors([
{
status: 413,
schema: z.never(),
},
])[0];
Loading