Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: external_module.go with sinks/sources build failures #1132

Merged
merged 3 commits into from
Mar 25, 2024

Conversation

matt2e
Copy link
Collaborator

@matt2e matt2e commented Mar 25, 2024

Fixes #1095

Sink & Source verbs would have a schema like

verb returnsUser(Unit) two.UserResponse

but the scaffolded external_module.go version of it would be:

func ReturnsUser(ctx context.Context) (UserResponse, error)

When generating imports, we were finding schema.Unit in the verb which triggered an inclusion of ftl
This caused the exernal module to fail to build because ftl was not being used by the generated code.

This fix now skips any unit in the schema if the parent is a verb

@alecthomas alecthomas mentioned this pull request Mar 24, 2024
@matt2e
Copy link
Collaborator Author

matt2e commented Mar 25, 2024

Looks like this is not an issue in Kotlin

@matt2e matt2e marked this pull request as ready for review March 25, 2024 00:53
return innerVisitExcludingMetadataChildren(n, []Node{}, visit)
}

func innerVisitExcludingMetadataChildren(n Node, parents []Node, visit func(n Node, parents []Node, next func() error) error) error {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be simpler to type switch on Verb, manually call Visit() on the Verb's children iff they're not Unit and don't call next() in that case.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't that an odd separation of concerns though? As in the needs of a specific go scaffolding use case compared to schema/visit.go providing ways to traverse the graph.
Currently this is also called when scaffolding Kotlin (which to be fair, might not be affected by a change like that, not 100% sure).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I see what you're saying, but no - this is supposed to be universal. It should be true in Kotlin too.

@matt2e matt2e requested a review from alecthomas March 25, 2024 02:16
@matt2e matt2e merged commit 16588c5 into main Mar 25, 2024
11 checks passed
@matt2e matt2e deleted the matt2e/imported-sinks-sources branch March 25, 2024 03:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Build fails when importing another module which doesn't use go-runtime/ftl
2 participants