Language: Go
Label: vulnerable
CWE: CWE-835 \u2014 Loop with Unreachable Exit Condition ('Infinite Loop')
The product contains an iteration or loop with an exit condition that cannot be reached, i.e., an infinite loop.

Code:
func New(model *openfgapb.AuthorizationModel) *TypeSystem {
	tds := make(map[string]*openfgapb.TypeDefinition, len(model.GetTypeDefinitions()))
	relations := make(map[string]map[string]*openfgapb.Relation, len(model.GetTypeDefinitions()))

	for _, td := range model.GetTypeDefinitions() {
		tds[td.GetType()] = td
		tdRelations := make(map[string]*openfgapb.Relation, len(td.GetRelations()))

		for relation, rewrite := range td.GetRelations() {
			r := &openfgapb.Relation{
				Name:     relation,
				Rewrite:  rewrite,
				TypeInfo: &openfgapb.RelationTypeInfo{},
			}

			if metadata, ok := td.GetMetadata().GetRelations()[relation]; ok {
				r.TypeInfo.DirectlyRelatedUserTypes = metadata.GetDirectlyRelatedUserTypes()
			}

			tdRelations[relation] = r
		}
		relations[td.GetType()] = tdRelations
	}

	return &TypeSystem{
		modelID:         model.GetId(),
		schemaVersion:   model.GetSchemaVersion(),
		typeDefinitions: tds,
		relations:       relations,
	}
}