You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2018/07/19 18:28:36 UTC

[GitHub] ccollins476ad closed pull request #196: Detect and report malformed `syscfg.yml` files

ccollins476ad closed pull request #196: Detect and report malformed `syscfg.yml` files
URL: https://github.com/apache/mynewt-newt/pull/196
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/newt/syscfg/syscfg.go b/newt/syscfg/syscfg.go
index 1685d065..16ddb529 100644
--- a/newt/syscfg/syscfg.go
+++ b/newt/syscfg/syscfg.go
@@ -441,7 +441,15 @@ func (cfg *Cfg) readDefsOnce(lpkg *pkg.LocalPackage,
 	defs := yc.GetValStringMap("syscfg.defs", lsettings)
 	if defs != nil {
 		for k, v := range defs {
-			vals := v.(map[interface{}]interface{})
+			vals, ok := v.(map[interface{}]interface{})
+			if !ok {
+				return util.FmtNewtError("Package \"%s\" contains invalid "+
+					"\"syscfg.defs\" map; expected full setting definition, "+
+					"but setting \"%s\" specifies a single value.  "+
+					"Did you mix up \"syscfg.defs\" and \"syscfg.vals\"?",
+					lpkg.FullName(), k)
+			}
+
 			entry, err := readSetting(k, lpkg, vals)
 			if err != nil {
 				return util.FmtNewtError("Config for package %s: %s",
@@ -515,6 +523,15 @@ func (cfg *Cfg) readValsOnce(lpkg *pkg.LocalPackage,
 
 	values := yc.GetValStringMap("syscfg.vals", lsettings)
 	for k, v := range values {
+		switch v.(type) {
+		case map[interface{}]interface{}, []interface{}:
+			return util.FmtNewtError("Package \"%s\" contains invalid "+
+				"\"syscfg.vals\" map; expected single value, but setting "+
+				"\"%s\" specifies multiple values.  Did you mix up "+
+				"\"syscfg.defs\" and \"syscfg.vals\"?",
+				lpkg.FullName(), k)
+		}
+
 		entry, ok := cfg.Settings[k]
 		if ok {
 			entry.appendValue(lpkg, v)


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services