do not proxy invalid object names (#20031)

This commit is contained in:
Harshavardhana 2024-07-02 14:28:55 -07:00 committed by GitHub
parent 2ec1f404ac
commit be84a4fd68
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 9 additions and 3 deletions

View File

@ -6,5 +6,5 @@ export GORACE="history_size=7"
export MINIO_API_REQUESTS_MAX=10000
for d in $(go list ./...); do
CGO_ENABLED=1 go test -v -race -short --timeout 100m "$d"
CGO_ENABLED=1 go test -v -race --timeout 100m "$d"
done

View File

@ -751,6 +751,12 @@ func isErrSignatureDoesNotMatch(err error) bool {
return errors.As(err, &signatureDoesNotMatch)
}
// isErrObjectNameInvalid - Check if error type is ObjectNameInvalid.
func isErrObjectNameInvalid(err error) bool {
var invalidObject ObjectNameInvalid
return errors.As(err, &invalidObject)
}
// PreConditionFailed - Check if copy precondition failed
type PreConditionFailed struct{}

View File

@ -502,7 +502,7 @@ func (api objectAPIHandlers) getObjectHandler(ctx context.Context, objectAPI Obj
perr error
)
// avoid proxying if version is a delete marker
if !isErrMethodNotAllowed(err) && !(gr != nil && gr.ObjInfo.DeleteMarker) {
if !isErrObjectNameInvalid(err) && !isErrMethodNotAllowed(err) && !(gr != nil && gr.ObjInfo.DeleteMarker) {
proxytgts := getProxyTargets(ctx, bucket, object, opts)
if !proxytgts.Empty() {
globalReplicationStats.incProxy(bucket, getObjectAPI, false)
@ -1028,7 +1028,7 @@ func (api objectAPIHandlers) headObjectHandler(ctx context.Context, objectAPI Ob
objInfo, err := getObjectInfo(ctx, bucket, object, opts)
var proxy proxyResult
if err != nil && !objInfo.DeleteMarker && !isErrMethodNotAllowed(err) {
if err != nil && !objInfo.DeleteMarker && !isErrMethodNotAllowed(err) && !isErrObjectNameInvalid(err) {
// proxy HEAD to replication target if active-active replication configured on bucket
proxytgts := getProxyTargets(ctx, bucket, object, opts)
if !proxytgts.Empty() {