MCPcopy Create free account
hub / github.com/github/gh-aw / extractAdditionalPropertyNames

Function extractAdditionalPropertyNames

pkg/parser/json_path_locator.go:242–265  ·  view source on GitHub ↗

extractAdditionalPropertyNames extracts property names from additional properties error messages Example: "additional properties 'invalid_prop', 'another_invalid' not allowed" -> ["invalid_prop", "another_invalid"]

(errorMessage string)

Source from the content-addressed store, hash-verified

240// extractAdditionalPropertyNames extracts property names from additional properties error messages
241// Example: "additional properties 'invalid_prop', 'another_invalid' not allowed" -> ["invalid_prop", "another_invalid"]
242func extractAdditionalPropertyNames(errorMessage string) []string {
243 // Look for the pattern: additional properties ... not allowed
244 // Use regex to match the full property list section
245 match := additionalPropertiesPattern.FindStringSubmatch(errorMessage)
246
247 if len(match) < 2 {
248 return []string{}
249 }
250
251 // Extract all quoted property names from the matched string
252 propMatches := quotedPropertyPattern.FindAllStringSubmatch(match[1], -1)
253
254 var properties []string
255 for _, propMatch := range propMatches {
256 if len(propMatch) > 1 {
257 prop := strings.TrimSpace(propMatch[1])
258 if prop != "" {
259 properties = append(properties, prop)
260 }
261 }
262 }
263
264 return properties
265}
266
267// findFirstAdditionalProperty finds the first occurrence of any of the given property names in YAML
268func findFirstAdditionalProperty(yamlContent string, propertyNames []string) JSONPathLocation {

Calls

no outgoing calls

Tested by 2