Skip to content

Commit d8161bf

Browse files
authored
fix(api): unescape model names (#9024)
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
1 parent 5fd4239 commit d8161bf

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

core/http/endpoints/localai/edit_model.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55
"io"
66
"net/http"
7+
"net/url"
78
"os"
89

910
"github.com/labstack/echo/v4"
@@ -20,6 +21,9 @@ import (
2021
func GetEditModelPage(cl *config.ModelConfigLoader, appConfig *config.ApplicationConfig) echo.HandlerFunc {
2122
return func(c echo.Context) error {
2223
modelName := c.Param("name")
24+
if decoded, err := url.PathUnescape(modelName); err == nil {
25+
modelName = decoded
26+
}
2327
if modelName == "" {
2428
response := ModelResponse{
2529
Success: false,
@@ -82,6 +86,9 @@ func GetEditModelPage(cl *config.ModelConfigLoader, appConfig *config.Applicatio
8286
func EditModelEndpoint(cl *config.ModelConfigLoader, ml *model.ModelLoader, appConfig *config.ApplicationConfig) echo.HandlerFunc {
8387
return func(c echo.Context) error {
8488
modelName := c.Param("name")
89+
if decoded, err := url.PathUnescape(modelName); err == nil {
90+
modelName = decoded
91+
}
8592
if modelName == "" {
8693
response := ModelResponse{
8794
Success: false,

core/http/routes/ui_api.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,9 @@ func RegisterUIAPIRoutes(app *echo.Echo, cl *config.ModelConfigLoader, ml *model
650650
// Get installed model YAML config for the React model editor
651651
app.GET("/api/models/edit/:name", func(c echo.Context) error {
652652
modelName := c.Param("name")
653+
if decoded, err := url.PathUnescape(modelName); err == nil {
654+
modelName = decoded
655+
}
653656
if modelName == "" {
654657
return c.JSON(http.StatusBadRequest, map[string]interface{}{
655658
"error": "model name is required",

0 commit comments

Comments
 (0)