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

msgp codegen requires structs to be pointers #114

Open
skaldesh opened this issue Sep 5, 2024 · 0 comments
Open

msgp codegen requires structs to be pointers #114

skaldesh opened this issue Sep 5, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@skaldesh
Copy link
Member

skaldesh commented Sep 5, 2024

The msgp codegen tool produces code like this:

// EncodeMsg implements msgp.Encodable
func (z *UpdateBatchOpClassifyAndPauseSettingsArg) EncodeMsg(en *msgp.Writer) (err error) {
	// map header, size 1
	// write "AnomalySeverities"
	fmt.Println("EncodeMsg from generated code")
	err = en.Append(0x81, 0xb1, 0x41, 0x6e, 0x6f, 0x6d, 0x61, 0x6c, 0x79, 0x53, 0x65, 0x76, 0x65, 0x72, 0x69, 0x74, 0x69, 0x65, 0x73)
	if err != nil {
		return
	}
	err = en.WriteArrayHeader(uint32(len(z.AnomalySeverities)))
	if err != nil {
		err = msgp.WrapError(err, "AnomalySeverities")
		return
	}
	for za0001 := range z.AnomalySeverities {
		err = en.WriteUint8(z.AnomalySeverities[za0001])
		if err != nil {
			err = msgp.WrapError(err, "AnomalySeverities", za0001)
			return
		}
	}
	return
}

But our orbit tool generates this:

func (v1 *client) UpdateBatchOpClassifyAndPauseSettings(ctx context.Context, arg UpdateBatchOpClassifyAndPauseSettingsArg) (err error) {
	if v1.callTimeout > 0 {
		var cancel context.CancelFunc
		ctx, cancel = context.WithTimeout(ctx, v1.callTimeout)
		defer cancel()
	}
	err = v1.Call(ctx, CallIDUpdateBatchOpClassifyAndPauseSettings, arg, nil)
	if err != nil {
		return
	}
	return
}

Note the missing Pointer of arg
This causes the generated msgp code to not being used, producing in the worst case incompatible encodings for the service side (or the other way around).

@skaldesh skaldesh self-assigned this Sep 5, 2024
@skaldesh skaldesh added the bug Something isn't working label Sep 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant