Skip to content

[Attributes] Potential mismatch in attributes relationship id #468

@zaeema-n

Description

@zaeema-n

In OpenGIN/opengin/core-api/engine/graph_metadata_manager.go, createAttributeLookUpGraph , the following code declares the relationship,

// the relationships map needs a unique key for each relationship
	// since the attribute id and the name of the attribute is unique for each attribute
	// among all entities, we can use this to form a unique key for the relationship
	relationshipId := GenerateAttributeRelationshipID()

	parentNode := &pb.Entity{
		Id:         metadata.EntityID,
		Metadata:   make(map[string]*anypb.Any),
		Attributes: make(map[string]*pb.TimeBasedValueList),
		Relationships: map[string]*pb.Relationship{
			relationshipId: MakeRelationshipFromAttributeMetadata(metadata),
		},
	}

A unique relationshipId is genarated as the key, however, within MakeRelationshipFromAttributeMetadata (in the same file), another unique id is generated for the relationship id again,

// MakeRelationshipProto creates a Relationship protobuf object for IS_ATTRIBUTE relationship
func MakeRelationshipFromAttributeMetadata(metadata *AttributeMetadata) *pb.Relationship {
	var endTime string
	if metadata.EndTime != nil {
		endTime = metadata.EndTime.Format(time.RFC3339)
	}
	return &pb.Relationship{
		Id:              GenerateAttributeRelationshipID(),
		RelatedEntityId: metadata.AttributeID,
		Name:            IS_ATTRIBUTE_RELATIONSHIP,
		StartTime:       metadata.Created.Format(time.RFC3339),
		EndTime:         endTime,
		Direction:       IS_ATTRIBUTE_RELATIONSHIP_DIRECTION,
	}
}

This causes a mismatch, check if this affects anything.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
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