fix: correctly sanitize comments out of the jsonc content

This commit is contained in:
Jose Diaz-Gonzalez committed 2025-11-20 00:35:17 -05:00
1 parent a05b79e2a9
commit 38505006e8
1 file changed
+8 -2
+8 -2
View File
@@ -1,13 +1,14 @@
package appjson package appjson
import ( import (
"encoding/json"
"fmt" "fmt"
"math" "math"
"os" "os"
"strings" "strings"
"github.com/dokku/dokku/plugins/common" "github.com/dokku/dokku/plugins/common"
json "github.com/marcozac/go-jsonc" "github.com/marcozac/go-jsonc"
"k8s.io/utils/ptr" "k8s.io/utils/ptr"
) )
@@ -262,8 +263,13 @@ func ReadAppJSON(path string) (AppJSON, error) {
return AppJSON{}, nil return AppJSON{}, nil
} }
data, err := jsonc.Sanitize(b)
if err != nil {
return AppJSON{}, fmt.Errorf("Cannot sanitize app.json: %v", err)
}
var appJSON AppJSON var appJSON AppJSON
if err = json.Unmarshal(b, &appJSON); err != nil { if err = json.Unmarshal(data, &appJSON); err != nil {
return AppJSON{}, fmt.Errorf("Cannot parse app.json: %v", err) return AppJSON{}, fmt.Errorf("Cannot parse app.json: %v", err)
} }