[LFXV2-1194] fix: handle msgpack-encoded v1-objects KV entries#9
[LFXV2-1194] fix: handle msgpack-encoded v1-objects KV entries#9
Conversation
v1 KV entries in the v1-objects bucket may be encoded as either JSON or msgpack. The handler was only attempting JSON deserialization, causing it to fail silently on msgpack-encoded entries. Add a fallback to msgpack when JSON deserialization fails, and add github.com/vmihailenco/msgpack/v5 as a dependency. Generated with [Claude Code](https://claude.com/claude-code) Signed-off-by: Andres Tobon <andrest2455@gmail.com>
There was a problem hiding this comment.
Pull request overview
This PR updates the survey service’s v1 NATS KV event handling to support KV entries encoded as either JSON or msgpack, improving compatibility with legacy v1 data formats.
Changes:
- Add a JSON-first, msgpack-fallback decoding path for v1 KV entry payloads.
- Introduce
github.com/vmihailenco/msgpack/v5as a direct dependency (and its transitive go.sum entries). - Document that v1 KV entries may be encoded as JSON or msgpack.
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
cmd/survey-api/eventing/kv_handler.go |
Implements JSON→msgpack fallback decoding for v1 KV PUT entries and tweaks prefix extraction. |
docs/event-processing.md |
Documents that v1 KV payloads may be JSON or msgpack and describes the fallback behavior. |
go.mod |
Adds msgpack dependency (and updates direct/indirect requirements). |
go.sum |
Records checksums for the newly added msgpack dependency and transitive modules. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…llback Store entry.Value() once in a local variable to avoid repeated method calls, and reset v1Data to a fresh map before the msgpack fallback to prevent stale keys from a partial JSON decode leaking into the result. Generated with [Claude Code](https://claude.com/claude-code) Signed-off-by: Andres Tobon <andrest2455@gmail.com>
mauriciozanettisalomao
left a comment
There was a problem hiding this comment.
Approved.
Maybe in the next PR, we can add a revive.toml to remove some lint warnings that we don’t usually address in the code anyway, like package-comments.
Thanks. Yeah we can have a |
Summary
json.Unmarshalcall with a two-step approach: try JSON first, fall back to msgpack if JSON failsgithub.com/vmihailenco/msgpack/v5as a direct dependencyTicket
LFXV2-1194