{"record":{"id":"7f239aa5b2eee34f","repo":"projectdiscovery/nuclei","slug":"can-t-get-example-for-array-item-v","errorCode":null,"errorMessage":"can't get example for array item: %+v","messagePattern":"can't get example for array item: %\\+v","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"pkg/input/formats/openapi/examples.go","lineNumber":229,"sourceCode":"\t\t\treturn ex, nil\n\t\t}\n\t\texample := \"string\"\n\n\t\tfor schema.MinLength > uint64(len(example)) {\n\t\t\texample += example\n\t\t}\n\n\t\tif schema.MaxLength != nil && *schema.MaxLength < uint64(len(example)) {\n\t\t\texample = example[:*schema.MaxLength]\n\t\t}\n\t\treturn example, nil\n\tcase schema.Type.Is(\"array\"), schema.Items != nil:\n\t\texample := []interface{}{}\n\n\t\tif schema.Items != nil && schema.Items.Value != nil {\n\t\t\tex, err := openAPIExample(schema.Items.Value, cache)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"can't get example for array item: %+v\", err)\n\t\t\t}\n\n\t\t\texample = append(example, ex)\n\n\t\t\tfor uint64(len(example)) < schema.MinItems {\n\t\t\t\texample = append(example, ex)\n\t\t\t}\n\t\t}\n\t\treturn example, nil\n\tcase schema.Type.Is(\"object\"), len(schema.Properties) > 0:\n\t\texample := map[string]interface{}{}\n\n\t\tfor k, v := range schema.Properties {\n\t\t\tif excludeFromMode(v.Value) {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tex, err := openAPIExample(v.Value, cache)","sourceCodeStart":211,"sourceCodeEnd":247,"githubUrl":"https://github.com/projectdiscovery/nuclei/blob/265b3a3dec374741614e342f813c10f8b38d2bb7/pkg/input/formats/openapi/examples.go#L211-L247","documentation":"While generating example request bodies from an OpenAPI 3 schema, openAPIExample failed to build an example for the items schema of an array (schema.Items.Value) and wraps the underlying error. The inner error is usually ErrRecursive (an array that directly or indirectly contains itself, e.g. Node[] whose items are $ref Node) or a nested 'can't get example for ...' failure; the affected operation/parameter loses its generated example.","triggerScenarios":"Recursive schemas: items: $ref: '#/components/schemas/Node' where Node itself has a children array of Node; an item schema with no recognizable type and no example/default/enum (ErrNoExample); an item whose nested object has a required property that is itself recursive.","commonSituations":"Specs for tree/graph APIs (categories, comments, org units) that model recursion with self-references; specs auto-generated from code where every type has a schema but few have examples; deeply nested DTOs.","solutions":["Add an explicit `example` (or `default`/`enum`) to the array's items schema so generation short-circuits (getSchemaExample checks example/default/enum first)","If the recursion is required, define the example at the array property level instead of per-item","Loosen artificial recursion (e.g. inline one level instead of self-$ref) if you control the spec","Ignore the failure if the affected endpoint is not in scope: only that operation's example is lost"],"exampleFix":"# before (recursive array item, no example)\nNode:\n  type: object\n  required: [children]\n  properties:\n    children:\n      type: array\n      items:\n        $ref: '#/components/schemas/Node'\n\n# after (explicit example short-circuits recursion)\n    children:\n      type: array\n      items:\n        $ref: '#/components/schemas/Node'\n      example: []","handlingStrategy":"fallback","validationCode":"// in the spec (before scanning): give every array items schema an example\ndefinitions:\n  Node:\n    type: object\n    properties:\n      children:\n        type: array\n        items: { $ref: '#/components/schemas/Node' }\n        example: []   # short-circuits recursive example generation","typeGuard":"func itemExampleResolvable(schema *openapi3.Schema) bool {\n    if schema.Example != nil || schema.Default != nil || len(schema.Enum) > 0 {\n        return true\n    }\n    return schema.Type != nil && !isSelfReferencing(schema)\n}","tryCatchPattern":"if _, err := generateExampleFromSchema(schema); err != nil {\n    if strings.Contains(err.Error(), \"can't get example for array item\") {\n        // fall back: use an empty array or skip this operation instead of failing the run\n    }\n}","preventionTips":["Add example/default/enum to recursive and untyped array item schemas","Lint specs for self-referencing $refs before scanning","Treat missing examples as per-endpoint degradation, not a fatal scan error"],"tags":["openapi","schema","example-generation","recursion"],"backgroundTag":null,"analyzedSha":"265b3a3dec374741614e342f813c10f8b38d2bb7","analyzedAt":"2026-08-15T20:05:51.855Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}