fix: handle nested Metadata types in structpb conversion #63
Merged
mfiedorowicz merged 2 commits intodevelopfrom Feb 5, 2026
Merged
fix: handle nested Metadata types in structpb conversion #63mfiedorowicz merged 2 commits intodevelopfrom
mfiedorowicz merged 2 commits intodevelopfrom
Conversation
Add convertMetadata helper function to recursively convert nested Metadata type values to map[string]any before passing to structpb.NewStruct, which doesn't recognize the Metadata type alias for nested maps.
Add unit tests for the convertMetadata function and integration test verifying nested Metadata types are properly converted to protobuf structs.
|
Go test coverage
Total coverage: 74.5% |
jajeffries
approved these changes
Feb 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request improves how entity metadata is handled when converting to protobuf
Structobjects. Specifically, it introduces a helper function to recursively convert nestedMetadatamaps, ensuring that all nested metadata is properly processed. This change is applied across all entity types that expose metadata, making metadata serialization more robust and reliable.Key changes:
Metadata Handling Improvements
convertMetadatato recursively convertMetadata(including nestedMetadatavalues) tomap[string]any, ensuring compatibility withstructpb.NewStruct.GetMetadatamethods (e.g.,ASN,ASNRange,Aggregate,Cable,CablePath,CableTermination,Circuit,CircuitGroup,CircuitGroupAssignment,CircuitTermination,CircuitType,Cluster,ClusterGroup,ClusterType,ConsolePort,ConsoleServerPort,Contact,ContactAssignment,ContactGroup,ContactRole,Device,DeviceBay,DeviceRole,DeviceType,FHRPGroup,FHRPGroupAssignment,FrontPort,IKEPolicy,IKEProposal,IPAddress,IPRange,IPSecPolicy,IPSecProfile,IPSecProposal,Interface) to useconvertMetadatabefore callingstructpb.NewStruct, ensuring correct handling of nested metadata. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [17] [18] [19] [20] [21] [22] [23] [24] [25] [26] [27] [28] [29] [30] [31] [32] [33] [34] [35]Other