fix: correctly sanitize comments out of the jsonc content

This commit is contained in:
Jose Diaz-Gonzalez
2025-11-17 04:19:21 -05:00
parent a05b79e2a9
commit 38505006e8

View File

@@ -1,13 +1,14 @@
package appjson
import (
"encoding/json"
"fmt"
"math"
"os"
"strings"
"github.com/dokku/dokku/plugins/common"
json "github.com/marcozac/go-jsonc"
"github.com/marcozac/go-jsonc"
"k8s.io/utils/ptr"
)
@@ -262,8 +263,13 @@ func ReadAppJSON(path string) (AppJSON, error) {
return AppJSON{}, nil
}
data, err := jsonc.Sanitize(b)
if err != nil {
return AppJSON{}, fmt.Errorf("Cannot sanitize app.json: %v", err)
}
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)
}