From 5785f037d237b50f5959e9ccfbabff9be1392f2c Mon Sep 17 00:00:00 2001 From: Shivansh Vij Date: Thu, 28 Apr 2022 15:39:31 -0400 Subject: [PATCH 1/2] Fix:(#108) Slice Decoding (#109) * Fixing the decoder bug in #108 * updating changelog * updating trunk linter and changelog --- .trunk/trunk.yaml | 2 +- CHANGELOG.md | 8 ++++++++ protoc-gen-frisbee/examples/simple/simple.proto | 5 +++++ protoc-gen-frisbee/templates/decode.templ | 3 +++ 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/.trunk/trunk.yaml b/.trunk/trunk.yaml index 6488aad..b087158 100644 --- a/.trunk/trunk.yaml +++ b/.trunk/trunk.yaml @@ -1,6 +1,6 @@ version: 0.1 cli: - version: 0.10.1-beta + version: 0.11.0-beta lint: enabled: - gitleaks@8.7.1 diff --git a/CHANGELOG.md b/CHANGELOG.md index e009d42..ede0bf2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,14 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +## Fixes + +- Fixing issue where generated `decode` functions for slices would not allocate the proper memory before decoding the slice values (Issue #108) + +## Changes + +- Updating Trunk Linter to `v0.11.0-beta` + ## [v0.4.5] - 2022-04-22 (Beta) ## Fixes diff --git a/protoc-gen-frisbee/examples/simple/simple.proto b/protoc-gen-frisbee/examples/simple/simple.proto index e8a86b1..d0a796c 100644 --- a/protoc-gen-frisbee/examples/simple/simple.proto +++ b/protoc-gen-frisbee/examples/simple/simple.proto @@ -19,4 +19,9 @@ message Request { message Response{ string Message = 1; +} + +message SliceResponse { + repeated Response ResponseSlice = 1; + map ResponseMap = 2; } \ No newline at end of file diff --git a/protoc-gen-frisbee/templates/decode.templ b/protoc-gen-frisbee/templates/decode.templ index bdbfe7d..8dc6e7d 100644 --- a/protoc-gen-frisbee/templates/decode.templ +++ b/protoc-gen-frisbee/templates/decode.templ @@ -53,6 +53,9 @@ func (x *{{CamelCase .FullName}}) decode(d *packet.Decoder) error { for i := uint32(0); i < sliceSize; i++ { {{ $decoder := GetLUTDecoder $field.Kind -}} {{ if eq $field.Kind 11 -}} {{/* protoreflect.MessageKind */ -}} + if x.{{ CamelCaseName $field.Name }}[i] == nil { + x.{{ CamelCaseName $field.Name }}[i] = New{{ CamelCase $field.Message.FullName }}() + } err = x.{{ CamelCaseName $field.Name }}[i].decode(d) {{ else -}} x.{{ CamelCaseName $field.Name }}[i], err = d{{ $decoder }}() From 665f1afe3607c860066670b7a4d0c8004c5a6c75 Mon Sep 17 00:00:00 2001 From: Shivansh Vij Date: Thu, 28 Apr 2022 15:45:15 -0400 Subject: [PATCH 2/2] updating changelog and dockerfile (#110) --- CHANGELOG.md | 5 ++++- protoc-gen-frisbee/dockerfile | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ede0bf2..247c92a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +## [v0.4.6] - 2022-04-28 (Beta) + ## Fixes - Fixing issue where generated `decode` functions for slices would not allocate the proper memory before decoding the slice values (Issue #108) @@ -255,7 +257,8 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). Initial Release of Frisbee -[unreleased]: https://github.com/loopholelabs/frisbee/compare/v0.4.5...HEAD +[unreleased]: https://github.com/loopholelabs/frisbee/compare/v0.4.6...HEAD +[v0.4.6]: https://github.com/loopholelabs/frisbee/compare/v0.4.5...v0.4.6 [v0.4.5]: https://github.com/loopholelabs/frisbee/compare/v0.4.4...v0.4.5 [v0.4.4]: https://github.com/loopholelabs/frisbee/compare/v0.4.3...v0.4.4 [v0.4.3]: https://github.com/loopholelabs/frisbee/compare/v0.4.2...v0.4.3 diff --git a/protoc-gen-frisbee/dockerfile b/protoc-gen-frisbee/dockerfile index f901311..e13fe71 100644 --- a/protoc-gen-frisbee/dockerfile +++ b/protoc-gen-frisbee/dockerfile @@ -2,7 +2,7 @@ FROM golang as builder ENV GOOS=linux GOARCH=amd64 CGO_ENABLED=0 -RUN go install github.com/loopholelabs/frisbee/protoc-gen-frisbee@v0.4.5 +RUN go install github.com/loopholelabs/frisbee/protoc-gen-frisbee@v0.4.6 # Note, the Docker images must be built for amd64. If the host machine architecture is not amd64 # you need to cross-compile the binary and move it into /go/bin. @@ -12,7 +12,7 @@ FROM scratch # Runtime dependencies LABEL "build.buf.plugins.runtime_library_versions.0.name"="github.com/loopholelabs/frisbee" -LABEL "build.buf.plugins.runtime_library_versions.0.version"="v0.4.5" +LABEL "build.buf.plugins.runtime_library_versions.0.version"="v0.4.6" COPY --from=builder /go/bin /