Skip to content

Fix protobuf namespace conflict with prefab-cloud-go#12

Merged
jkebinger merged 1 commit into
mainfrom
fix/proto-namespace-conflict
Oct 30, 2025
Merged

Fix protobuf namespace conflict with prefab-cloud-go#12
jkebinger merged 1 commit into
mainfrom
fix/proto-namespace-conflict

Conversation

@jkebinger
Copy link
Copy Markdown
Contributor

Summary

Fixes the protobuf type namespace conflict that occurs when sdk-go and prefab-cloud-go are used together in the same binary.

Problem

Both packages were registering types in the same protobuf namespace (prefab.*), causing a runtime panic:

panic: proto: file "prefab.proto" has a name conflict over prefab.OnFailure
    previously from: "github.com/ReforgeHQ/sdk-go/proto"
    currently from:  "github.com/prefab-cloud/prefab-cloud-go/proto"

The original issue was two-fold:

  1. Filename collision: Both registered as "prefab.proto"
  2. Namespace collision: Both used package prefab; creating types like prefab.OnFailure, prefab.ConfigValue, etc.

Solution

Modified the proto compilation script to:

  1. Copy prefab.protoreforge.proto (fixes filename collision)
  2. Replace package prefab; with package reforge; (fixes namespace collision)
  3. Compile the modified temporary copy
  4. Clean up temporary files

Now the protobuf types are registered as:

  • reforge.OnFailure instead of prefab.OnFailure
  • reforge.ConfigValue instead of prefab.ConfigValue
  • etc.

The source proto file (git submodule) remains unchanged.

Changes

  • proto/reforge.pb.go - Regenerated with new namespace
  • scripts/compile-protos.sh - Added sed command to change package name during build

Test plan

  • Build succeeds: go build ./...
  • All tests pass: make test (561 tests)
  • Verify both SDKs can coexist in same binary without panic (requires integration test with both packages)

🤖 Generated with Claude Code

Change the protobuf package namespace from "prefab" to "reforge" to avoid
type registration conflicts when sdk-go and prefab-cloud-go are used together
in the same binary.

Previously, both packages were registering types like prefab.OnFailure,
prefab.ConfigValue, etc. in the global protobuf type registry, causing a
panic at runtime:

  panic: proto: file "prefab.proto" has a name conflict over prefab.OnFailure
    previously from: "github.com/ReforgeHQ/sdk-go/proto"
    currently from:  "github.com/prefab-cloud/prefab-cloud-go/proto"

The compilation script now:
1. Copies prefab.proto to reforge.proto (avoiding filename collision)
2. Changes "package prefab;" to "package reforge;" (avoiding namespace collision)
3. Compiles the modified copy
4. Cleans up temporary files

This allows both SDKs to coexist without conflicts in either the file
descriptor registry or the type namespace registry.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@jdwyah jdwyah left a comment

Choose a reason for hiding this comment

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

thanks

@jkebinger jkebinger merged commit f2cf9bc into main Oct 30, 2025
4 checks passed
@jkebinger jkebinger deleted the fix/proto-namespace-conflict branch October 30, 2025 18:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants