{"record":{"id":"85cd4c62da510d3d","repo":"theonedev/onedev","slug":"format-parameter-should-be-specified-either-zip-or","errorCode":null,"errorMessage":"format parameter should be specified either zip or tar.gz","messagePattern":"format parameter should be specified either zip or tar\\.gz","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/web/resource/ArchiveResource.java","lineNumber":69,"sourceCode":"\tprivate static final String PARAM_FORMAT = \"format\";\n\t\n\tpublic static final String FORMAT_ZIP = \"zip\";\n\t\n\tpublic static final String FORMAT_TGZ = \"tgz\";\n\t\n\t@Override\n\tprotected ResourceResponse newResourceResponse(Attributes attributes) {\n\t\tPageParameters params = attributes.getParameters();\n\n\t\tLong projectId = params.get(PARAM_PROJECT).toLong();\n\t\t\n\t\tString revision = params.get(PARAM_REVISION).toString();\n\t\tif (StringUtils.isBlank(revision))\n\t\t\tthrow new IllegalArgumentException(\"revision parameter has to be specified\");\n\t\t\n\t\tString format = params.get(PARAM_FORMAT).toString();\n\t\tif (!FORMAT_ZIP.equals(format) && !FORMAT_TGZ.equals(format)) {\n\t\t\tthrow new IllegalArgumentException(\"format parameter should be specified either zip or tar.gz\");\n\t\t}\n\t\t\n\t\tif (!SecurityUtils.isSystem()) {\n\t\t\t// Perform database operations only if it is not a cluster access to avoid possible deadlocks\n\t\t\tProject project = OneDev.getInstance(ProjectService.class).load(projectId);\n\t\t\tif (!SecurityUtils.canReadCode(project)) \n\t\t\t\tthrow new UnauthorizedException();\n\t\t}\n\t\t\n\t\tResourceResponse response = new ResourceResponse();\n\t\tresponse.setContentType(MimeTypes.OCTET_STREAM);\n\t\t\n\t\tresponse.disableCaching();\n\t\t\n\t\ttry {\n\t\t\tString fileName;\n\t\t\tif (GitUtils.ref2branch(revision) != null)\n\t\t\t\tfileName = GitUtils.ref2branch(revision);","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/web/resource/ArchiveResource.java#L51-L87","documentation":"ArchiveResource validates the 'format' parameter and only accepts \"zip\" or \"tar.gz\" (constants FORMAT_ZIP/FORMAT_TGZ). Any other value, including an absent or misspelled format, triggers this IllegalArgumentException because the resource cannot pick an archiving strategy.","triggerScenarios":"Requesting the archive resource with format=<anything other than zip or tar.gz>, or omitting the format parameter entirely so it is null/blank.","commonSituations":"Typo like 'gzip', 'tar', or 'tgz' instead of the exact 'tar.gz'; dropping the parameter when hand-crafting the URL; proxies or scripts URL-rewriting that mangle the query string.","solutions":["Set format=zip or format=tar.gz exactly in the archive URL","If defaulting is desired, add the format explicitly in your script rather than relying on omission","Check for typos/encoding issues in the query string (e.g. 'tar%2Egz' still decodes to 'tar.gz' and is fine, but 'tar .gz' is not)"],"exampleFix":"// before\nGET /~resources/archive?project=1&revision=main&format=gzip\n// after\nGET /~resources/archive?project=1&revision=main&format=tar.gz","handlingStrategy":"validation","validationCode":"const FORMAT_ZIP='zip', FORMAT_TGZ='tar.gz';\nif (format !== FORMAT_ZIP && format !== FORMAT_TGZ) throw new Error(`format must be '${FORMAT_ZIP}' or '${FORMAT_TGZ}', got: ${format}`);","typeGuard":"function isArchiveFormat(f) { return f === 'zip' || f === 'tar.gz'; }","tryCatchPattern":null,"preventionTips":["Use the exact literals 'zip' or 'tar.gz'","Do not omit format hoping for a default","Centralize archive URL construction in one helper"],"tags":["http","invalid-parameter","archive"],"backgroundTag":"invalid-enum-value","analyzedSha":"d44925c47c37992c828ea673a5f9620539bc3ff2","analyzedAt":"2026-09-06T07:18:27.995Z","contentChangedAt":"2026-09-06T07:18:27.995Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}