projectdiscovery/nuclei · warning

can't get example for additional properties: %+v

Error message

can't get example for additional properties: %+v

What it means

The object schema declares additionalProperties with a schema, and generating an example for that schema failed with a non-recursive error (ErrNoExample or a deeper wrapped failure). The additionalProperties entry would have been emitted under the placeholder key 'additionalPropertyName'; instead the whole object example generation fails.

Source

Thrown at pkg/input/formats/openapi/examples.go:267

				if isRequired(schema, k) {
					return nil, fmt.Errorf("can't get example for '%s': %+v", k, err)
				}
			} else if err != nil {
				return nil, fmt.Errorf("can't get example for '%s': %+v", k, err)
			} else {
				example[k] = ex
			}
		}

		if schema.AdditionalProperties.Has != nil && schema.AdditionalProperties.Schema != nil {
			addl := schema.AdditionalProperties.Schema.Value

			if !excludeFromMode(addl) {
				ex, err := openAPIExample(addl, cache)
				if err == ErrRecursive {
					// We just won't add this if it's recursive.
				} else if err != nil {
					return nil, fmt.Errorf("can't get example for additional properties: %+v", err)
				} else {
					example["additionalPropertyName"] = ex
				}
			}
		}
		return example, nil
	}
	return nil, ErrNoExample
}

// generateExampleFromSchema creates an example structure from an OpenAPI 3 schema
// object, which is an extended subset of JSON Schema.
//
// https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#schemaObject
func generateExampleFromSchema(schema *openapi3.Schema) (interface{}, error) {
	return openAPIExample(schema, make(map[*openapi3.Schema]*cachedSchema)) // TODO: Use caching
}

View on GitHub (pinned to 265b3a3dec)

Solutions

  1. Add an `example` or concrete `type` to the additionalProperties schema
  2. Drop the schema under additionalProperties if map values are truly free-form (a bare additionalProperties: true is not generated and does not fail)
  3. Fix the nested cause named in the %v portion of the message

Example fix

# before
additionalProperties:
  type: object
  properties:
    v: {}   # untyped -> ErrNoExample

# after
additionalProperties:
  type: string
  example: "value"
Defensive patterns

Strategy: fallback

Validate before calling

// spec check: additionalProperties with schema must carry a type or example
if ap := schema.AdditionalProperties; ap.Has != nil && ap.Schema != nil {
    s := ap.Schema.Value
    if s.Type == nil && s.Example == nil && s.Default == nil && len(s.Enum) == 0 {
        return fmt.Errorf("additionalProperties schema has no derivable example")
    }
}

Try / catch

if _, err := generateExampleFromSchema(schema); err != nil {
    if strings.Contains(err.Error(), "can't get example for additional properties") {
        // omit the additionalProperties schema (free-form maps generate nothing) and retry
    }
}

Prevention

When it happens

Trigger: additionalProperties: { type: object, properties: { x: {} } } where the inner schema is untyped with no example; additionalProperties referencing a schema that itself contains ungeneratable properties.

Common situations: Map/dictionary-typed payloads (additionalProperties as the map value schema); strict specs that add additionalProperties: false plus a schema block; code-generated specs attaching complex free-form value schemas.

Related errors


AI-assisted analysis of projectdiscovery/nuclei@265b3a3dec (2026-08-15). Data as JSON: /api/errors/459237ddd9e45415. Report an issue: GitHub.