Skip to content
New issue

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

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

Already on GitHub? # to your account

nested message with default values regression #256

Open
kobykahane opened this issue Nov 19, 2023 · 1 comment
Open

nested message with default values regression #256

kobykahane opened this issue Nov 19, 2023 · 1 comment
Labels

Comments

@kobykahane
Copy link

With the latest lua-protobuf master, the assertion on the last line of this program is hit:

pb = require 'pb'
protoc = require 'protoc'

assert(protoc:load[[
syntax = "proto3";

package repro;

message Inner {
    string value = 1;
}

message Outer {
    Inner inner = 1;
}
]])

outer = {inner={value=""}}

assert(outer)
assert(outer.inner)

m = assert(pb.decode('repro.Outer', assert(pb.encode('repro.Outer', outer))))

assert(m.inner, 'inner')

As follows:

lua5.4: repro.lua:25: inner
stack traceback:
        [C]: in function 'assert'
        repro.lua:25: in main chunk
        [C]: in ?

This does not happen with older versions of lua-protobuf. After a git bisect, I've narrowed the change in behavior down to commit 7de8652. From the commit description, this change does not appear to be intentional.

@starwing
Copy link
Owner

This commit fix a encode bug, if you need default message, use option "decode_default_message"

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants