Skip to content

Commit

Permalink
Fix dependency type management
Browse files Browse the repository at this point in the history
See comment in `RegisterManifests`, depednency types _must_ be registered.
  • Loading branch information
PapaCharlie committed Apr 2, 2024
1 parent 4ae0f30 commit 994ceb0
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions v2/cmd/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,14 @@ func RegisterManifests(manifests []*GoRestliManifest) (err error) {
}
}

// Only use the final (input) manifest to resolve dependency data types, that way types that are not defined as
// input types by this manifest or upstream manifests always come from the same place. If the dependency types of
// previous packages is used, the import location may spuriously change depending on the order in which upstream
// manifests are discovered
inputManifest := manifests[len(manifests)-1]
for _, dt := range inputManifest.DependencyDataTypes {
_ = utils.TypeRegistry.Register(dt.GetComplexType(), inputManifest.PackageRoot)
// Always register the input types first, then the dependency types. Even though this can cause some
// flakiness in terms of which package these types are coming from, they are still required to
// generate/build. Without a definitive home for such types (i.e. without them being defined as input
// types), it is undetermined which package will be used if they are present in multiple packages.
for _, m := range manifests {
for _, dt := range m.DependencyDataTypes {
_ = utils.TypeRegistry.Register(dt.GetComplexType(), m.PackageRoot)
}
}
return utils.TypeRegistry.Finalize()
}
Expand Down

0 comments on commit 994ceb0

Please sign in to comment.