Skip to content

Endless recursion when running make generate for recursive types #47

Description

@jake-volvo

What happened?

I am working on an crossplane-runtime based Elasticsearch provider. One of the things I'd like to automate is the lifecycle of Ingest Pipelines. As you can see in the docs there is a recursive "on_failure" element to the API call.

An example of a real, even more nested ingest pipeline:

   "processors": [
     {
       "rename": {
         "description": "Rename 'provider' to 'my.field'",
         "field": "field",
         "target_field": "my.field",
         "on_failure": [
           {
             "set": {
               "description": "Set 'error.message'",
               "field": "error.message",
               "value": "Field 'field' does not exist. Cannot rename to 'my.field'",
               "override": false,
               "on_failure": [
                 {
                   "set": {
                     "description": "Set 'error.message.multi'",
                     "field": "error.message.multi",
                     "value": "Document encountered multiple ingest errors",
                     "override": true
                   }
                 }
               ]
             }
           }
         ]
       }
     }
   ]

How can we reproduce it?

An example with some irrelevant fields omitted:

type OpensearchIndexPipelineSpec struct {
	xpv1.ResourceSpec `json:",inline"`
	Description       string                  `json:"description"`
	Version           int64                   `json:"version"`
	Processors        []*PipelineProcessorSpec `json:"processors"`
}

type PipelineProcessorSpec struct {
	Set *SetProcessorSpec `json:"set,omitempty"`
	Rename *RenameProcessorSpec `json:"rename,omitempty"`
}

type SetProcessorSpec struct {
	Field string `json:"field,omitempty"`
	Value string `json:"value,omitempty"`
	Description string `json:"description,omitempty"`
	Override    bool   `json:"override,omitempty"`
	OnFailure []PipelineProcessorSpec `json:"on_failure,omitempty"`
}

type RenameProcessorSpec struct {
	Field       string `json:"field,omitempty"`
	TargetField string `json:"target_field,omitempty"`
	OnFailure []PipelineProcessorSpec `json:"on_failure,omitempty"`
}

run make generate

The generation will fail due to endless recursion in https://github.com/crossplane/crossplane-tools/blob/master/internal/types/types.go#L89

What environment did it happen in?

crossplane-provider template tip

I have a patch ready and will send it shortly.

Cheers

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions