-
Notifications
You must be signed in to change notification settings - Fork 99
feat: add error handling for unsupported model formats in manager #192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,10 +12,10 @@ import ( | |
| "strings" | ||
| "sync" | ||
|
|
||
| "github.com/docker/model-runner/pkg/diskusage" | ||
| "github.com/docker/model-runner/pkg/distribution/distribution" | ||
| "github.com/docker/model-runner/pkg/distribution/registry" | ||
| "github.com/docker/model-runner/pkg/distribution/types" | ||
| "github.com/docker/model-runner/pkg/diskusage" | ||
| "github.com/docker/model-runner/pkg/inference" | ||
| "github.com/docker/model-runner/pkg/inference/memory" | ||
| "github.com/docker/model-runner/pkg/logging" | ||
|
|
@@ -196,6 +196,11 @@ func (m *Manager) handleCreateModel(w http.ResponseWriter, r *http.Request) { | |
| http.Error(w, "Model not found", http.StatusNotFound) | ||
| return | ||
| } | ||
| if errors.Is(err, distribution.ErrUnsupportedFormat) { | ||
| m.log.Warnf("Unsupported model format for %q: %v", request.From, err) | ||
| http.Error(w, distribution.ErrUnsupportedFormat.Error(), http.StatusBadRequest) | ||
| return | ||
| } | ||
|
Comment on lines
+199
to
+203
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While this new error handling for For better consistency and an improved user experience, consider refactoring the other error handling cases in For example, for // Before
http.Error(w, "Model not found", http.StatusNotFound)
// After (suggested)
http.Error(w, err.Error(), http.StatusNotFound)This would provide more context to the user, which is a pattern already used by other handlers in this file, such as |
||
| http.Error(w, err.Error(), http.StatusInternalServerError) | ||
| return | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.