{"record":{"id":"bd17e81c5e551a93","repo":"theonedev/onedev","slug":"not-allowed-file-type-0","errorCode":null,"errorMessage":"Not allowed file type: {0}","messagePattern":"Not allowed file type: (.+?)","errorType":"exception","errorClass":"BlobEditException","httpStatus":null,"severity":"warning","filePath":"server-core/src/main/java/io/onedev/server/web/page/project/blob/ProjectBlobPage.java","lineNumber":1629,"sourceCode":"\t\t\tif (parentPath != null)\n\t\t\t\tparentPath += \"/\" + directory;\n\t\t\telse\n\t\t\t\tparentPath = directory;\n\t\t}\n\t\t\n\t\tUser user = Preconditions.checkNotNull(SecurityUtils.getAuthUser());\n\t\tBlobIdent blobIdent = getBlobIdent();\n\t\t\n\t\tboolean signRequired = false;\n\t\tfor (var item: upload.getItems()) {\n\t\t\tString blobPath = FilenameUtils.sanitizeFileName(FileUpload.getFileName(item));\n\t\t\tif (parentPath != null)\n\t\t\t\tblobPath = parentPath + \"/\" + blobPath;\n\t\t\tvar blobType = FileExtension.getExtension(blobPath);\n\n\t\t\tvar disallowedFileTypes = getProject().getBranchProtection(blobIdent.revision, user).getDisallowedFileTypes();\n\t\t\tif (disallowedFileTypes.stream().anyMatch(type -> type.equalsIgnoreCase(blobType))) {\n\t\t\t\tthrow new BlobEditException(MessageFormat.format(_T(\"Not allowed file type: {0}\"), blobType));\n\t\t\t}\n\n\t\t\tif (getProject().isReviewRequiredForModification(user, blobIdent.revision, blobPath)) \n\t\t\t\tthrow new BlobEditException(_T(\"Review required for this change. Please submit pull request instead\"));\n\t\t\telse if (getProject().isBuildRequiredForModification(user, blobIdent.revision, blobPath)) \n\t\t\t\tthrow new BlobEditException(_T(\"Build required for this change. Please submit pull request instead\"));\n\t\t\telse if (getProject().isCommitSignatureRequiredButNoSigningKey(user, blobIdent.revision)) \n\t\t\t\tsignRequired = true;\n\t\t\t\n\t\t\tBlobContent blobContent = new BlobContent(item.get(), FileMode.REGULAR_FILE.getBits());\n\t\t\tnewBlobs.put(blobPath, blobContent);\n\t\t}\n\n\t\tBlobEdits blobEdits = new BlobEdits(Sets.newHashSet(), newBlobs);\n\t\tString refName = blobIdent.revision!=null? GitUtils.branch2ref(blobIdent.revision):\"refs/heads/main\";\n\n\t\tObjectId prevCommitId;\n\t\tif (blobIdent.revision != null)","sourceCodeStart":1611,"sourceCodeEnd":1647,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/web/page/project/blob/ProjectBlobPage.java#L1611-L1647","documentation":"During a blob edit/save, ProjectBlobPage checks the target branch's protection settings for disallowed file types. If the file's extension matches one of them (case-insensitive), a BlobEditException with the localized message 'Not allowed file type: {0}' is thrown and the commit is rejected.","triggerScenarios":"Committing/renaming/adding a file via the web editor whose extension is on the branch protection's disallowed file types list (e.g. .exe, .jar).","commonSituations":"Uploading binaries to a protected branch from the web UI; branch protection recently tightened; extension casing like .EXE still matched via equalsIgnoreCase.","solutions":["Remove the file type from the branch protection's disallowed file types list (Branch Protection -> Disallowed File Types)","Use a different file format or host the artifact outside the repository","Commit via a pull request from an unprotected branch if policy permits"],"exampleFix":"// before: committing build/app.exe to protected main with '*.exe' disallowed\n// after: remove '*.exe' from branch protection, or commit to a feature branch and open a PR","handlingStrategy":"validation","validationCode":"var ext = FileExtension.getExtension(blobPath);\nvar disallowed = project.getBranchProtection(revision, user).getDisallowedFileTypes();\nif (disallowed.stream().anyMatch(t -> t.equalsIgnoreCase(ext))) { /* block before save */ }","typeGuard":null,"tryCatchPattern":"try {\n    saveBlob();\n} catch (BlobEditException e) {\n    showSaveError(e.getMessage());\n}","preventionTips":["Review branch protection disallowed-file-types before committing binary files","Use feature branches when main disallows your file type","Keep the editor's file-type filter aware of branch rules"],"tags":["branch-protection","file-type","blob-edit","commit-rejected"],"backgroundTag":"permission-denied","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"}