@@ -140,6 +140,46 @@ def test_valid_map():
140140 vd .SCHEMA_ADDON_CONFIG (config )
141141
142142
143+ def test_malformed_map_entries ():
144+ """Test that malformed map entries are handled gracefully (issue #6124)."""
145+ config = load_json_fixture ("basic-addon-config.json" )
146+
147+ # Test case 1: Empty dict in map (should be skipped with warning)
148+ config ["map" ] = [{}]
149+ valid_config = vd .SCHEMA_ADDON_CONFIG (config )
150+ assert valid_config ["map" ] == []
151+
152+ # Test case 2: Dict missing required 'type' field (should be skipped with warning)
153+ config ["map" ] = [{"read_only" : False , "path" : "/custom" }]
154+ valid_config = vd .SCHEMA_ADDON_CONFIG (config )
155+ assert valid_config ["map" ] == []
156+
157+ # Test case 3: Invalid string format that doesn't match regex
158+ config ["map" ] = ["invalid_format" , "not:a:valid:mapping" , "share:invalid_mode" ]
159+ valid_config = vd .SCHEMA_ADDON_CONFIG (config )
160+ assert valid_config ["map" ] == []
161+
162+ # Test case 4: Mix of valid and invalid entries (invalid should be filtered out)
163+ config ["map" ] = [
164+ "share:rw" , # Valid string format
165+ "invalid_string" , # Invalid string format
166+ {}, # Invalid empty dict
167+ {"type" : "config" , "read_only" : True }, # Valid dict format
168+ {"read_only" : False }, # Invalid - missing type
169+ ]
170+ valid_config = vd .SCHEMA_ADDON_CONFIG (config )
171+ # Should only keep the valid entries
172+ assert len (valid_config ["map" ]) == 2
173+ assert any (entry ["type" ] == "share" for entry in valid_config ["map" ])
174+ assert any (entry ["type" ] == "config" for entry in valid_config ["map" ])
175+
176+ # Test case 5: The specific case from the UplandJacob repo (malformed YAML format)
177+ # This simulates what YAML "- addon_config: rw" creates
178+ config ["map" ] = [{"addon_config" : "rw" }] # Wrong structure, missing 'type' key
179+ valid_config = vd .SCHEMA_ADDON_CONFIG (config )
180+ assert valid_config ["map" ] == []
181+
182+
143183def test_valid_basic_build ():
144184 """Validate basic build config."""
145185 config = load_json_fixture ("basic-build-config.json" )
0 commit comments