goharbor/harbor · error · ErrImmutable

PRECONDITION

PRECONDITION

Error message

Failed to process request due to '%s:%s' configured as immutable.

What it means

Error "Failed to process request due to '%s:%s' configured as immutable." thrown in goharbor/harbor.

Source

Thrown at src/server/middleware/immutable/pushmf.go:37

	"net/http"

	common_util "github.com/goharbor/harbor/src/common/utils"
	"github.com/goharbor/harbor/src/controller/artifact"
	"github.com/goharbor/harbor/src/controller/tag"
	"github.com/goharbor/harbor/src/lib"
	errors "github.com/goharbor/harbor/src/lib/errors"
	lib_http "github.com/goharbor/harbor/src/lib/http"
	"github.com/goharbor/harbor/src/lib/log"
)

// Middleware ...
func Middleware() func(http.Handler) http.Handler {
	return func(next http.Handler) http.Handler {
		return http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
			if err := handlePush(req); err != nil {
				var e *ErrImmutable
				if errors.As(err, &e) {
					pkgE := errors.New(e).WithCode(errors.PreconditionCode)
					lib_http.SendError(rw, pkgE)
					return
				}
				pkgE := errors.New(fmt.Errorf("error occurred when to handle request in immutable handler: %v", err)).WithCode(errors.GeneralCode)
				lib_http.SendError(rw, pkgE)
				return
			}
			next.ServeHTTP(rw, req)
		})
	}
}

// handlePush ...
// If the pushing image matched by any of immutable rule, will have to whether it is the first time to push it,
// as the immutable rule only impacts the existing tag.
func handlePush(req *http.Request) error {
	none := lib.ArtifactInfo{}
	art := lib.GetArtifactInfo(req.Context())

View on GitHub (pinned to 7b2fd08cc5)

When it happens

Trigger: Thrown at src/server/middleware/immutable/pushmf.go:37 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of goharbor/harbor@7b2fd08cc5 (2026-08-16). Data as JSON: /api/errors/ef129ec313097c56. Report an issue: GitHub.