Skip to content

Commit 70aaaf2

Browse files
committed
Make pull errors symetrical with push
Return Unauthorized status when appropriate. Signed-off-by: Emily Casey <[email protected]>
1 parent e6bb211 commit 70aaaf2

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

pkg/inference/models/manager.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,12 @@ func (m *Manager) handleCreateModel(w http.ResponseWriter, r *http.Request) {
133133
http.Error(w, "Invalid model reference", http.StatusBadRequest)
134134
return
135135
}
136-
if errors.Is(err, distribution.ErrUnauthorized) || errors.Is(err, distribution.ErrModelNotFound) {
136+
if errors.Is(err, distribution.ErrUnauthorized) {
137+
m.log.Warnf("Unauthorized to pull model %q: %v", request.From, err)
138+
http.Error(w, "Unauthorized", http.StatusUnauthorized)
139+
return
140+
}
141+
if errors.Is(err, distribution.ErrModelNotFound) {
137142
m.log.Warnf("Failed to pull model %q: %v", request.From, err)
138143
http.Error(w, "Model not found", http.StatusNotFound)
139144
return
@@ -369,7 +374,7 @@ func (m *Manager) handlePushModel(w http.ResponseWriter, r *http.Request, model
369374
return
370375
}
371376
if errors.Is(err, distribution.ErrUnauthorized) {
372-
m.log.Warnf("Failed to push model %q: %v", model, err)
377+
m.log.Warnf("Unauthorized to push model %q: %v", model, err)
373378
http.Error(w, "Unauthorized", http.StatusUnauthorized)
374379
return
375380
}

0 commit comments

Comments
 (0)