{"record":{"id":"ef129ec313097c56","repo":"goharbor/harbor","slug":"precondition-ef129e","errorCode":"PRECONDITION","errorMessage":"Failed to process request due to '%s:%s' configured as immutable.","messagePattern":"Failed to process request due to '(.+?):(.+?)' configured as immutable\\.","errorType":"http","errorClass":"ErrImmutable","httpStatus":412,"severity":"error","filePath":"src/server/middleware/immutable/pushmf.go","lineNumber":37,"sourceCode":"\t\"net/http\"\n\n\tcommon_util \"github.com/goharbor/harbor/src/common/utils\"\n\t\"github.com/goharbor/harbor/src/controller/artifact\"\n\t\"github.com/goharbor/harbor/src/controller/tag\"\n\t\"github.com/goharbor/harbor/src/lib\"\n\terrors \"github.com/goharbor/harbor/src/lib/errors\"\n\tlib_http \"github.com/goharbor/harbor/src/lib/http\"\n\t\"github.com/goharbor/harbor/src/lib/log\"\n)\n\n// Middleware ...\nfunc Middleware() func(http.Handler) http.Handler {\n\treturn func(next http.Handler) http.Handler {\n\t\treturn http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {\n\t\t\tif err := handlePush(req); err != nil {\n\t\t\t\tvar e *ErrImmutable\n\t\t\t\tif errors.As(err, &e) {\n\t\t\t\t\tpkgE := errors.New(e).WithCode(errors.PreconditionCode)\n\t\t\t\t\tlib_http.SendError(rw, pkgE)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tpkgE := errors.New(fmt.Errorf(\"error occurred when to handle request in immutable handler: %v\", err)).WithCode(errors.GeneralCode)\n\t\t\t\tlib_http.SendError(rw, pkgE)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tnext.ServeHTTP(rw, req)\n\t\t})\n\t}\n}\n\n// handlePush ...\n// If the pushing image matched by any of immutable rule, will have to whether it is the first time to push it,\n// as the immutable rule only impacts the existing tag.\nfunc handlePush(req *http.Request) error {\n\tnone := lib.ArtifactInfo{}\n\tart := lib.GetArtifactInfo(req.Context())","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/goharbor/harbor/blob/7b2fd08cc568955cca339afeefab27372840d936/src/server/middleware/immutable/pushmf.go#L19-L55","documentation":"Error \"Failed to process request due to '%s:%s' configured as immutable.\" thrown in goharbor/harbor.","triggerScenarios":"Thrown at src/server/middleware/immutable/pushmf.go:37 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7b2fd08cc568955cca339afeefab27372840d936","analyzedAt":"2026-08-16T00:00:10.961Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}