Skip to content

Correct Event Field-Type Imports in Generated Code

Latest

Choose a tag to compare

@bw19 bw19 released this 19 Jun 17:51
· 1 commit to main since this release

A patch release that fixes cmd/genservice so a microservice's generated intermediate.go always imports exactly the packages its event handlers reference — no more, no less. Two cases could previously emit an intermediate.go that did not compile, both only when an event carried a non-scalar field type (e.g. time.Time, net/url.URL, net/netip.Addr); events with purely scalar fields were unaffected, which is why the issue slipped past v1.41.0. There is no change to definition.go, to the authoring model, or to any runtime behavior. Pick up the fix by upgrading the module and re-running cmd/genservice (the housekeeping skill does both).

Bug Fixes

  • Missing import on an inbound event sink (compile error). An inbound event's handler signature references the field types of the source OutboundEvent. When a source field was non-scalar, the generated intermediate.go referenced that type's package without importing it, so the file did not compile. genservice now resolves the source event's field-type packages — against the source package's own import aliases — and adds them to intermediate.go.
  • Unused import on an outbound event producer (compile error). The import scan walked every feature's In/Out types, so an outbound event's field-type packages leaked into the producer's intermediate.go even though the producer has no handler for that event — it is fired through the Trigger in client.go. The generated file then carried an unused import and did not compile. The scan is now filtered by feature kind: intermediate.go considers only the kinds it actually wires handlers for (functions, web handlers, tasks, workflows, and inbound event sinks), while the outbound event's field types remain imported where they belong, in client.go.

Migration

This is a drop-in generator fix; no source changes are required. From inside a Microbus project, ask Claude Code to upgrade Microbus:

Get the latest version of Microbus.

The upgrade bumps go.mod to v1.41.1, runs go mod tidy, and regenerates each microservice with cmd/genservice, which repairs the imports in any affected intermediate.go. If you are already on v1.41.0, re-running the housekeeping skill (or cmd/genservice directly) on each microservice is sufficient. Run go vet ./... afterward to confirm a clean build.