Conversation
ReadEntities packed entity names as raw UTF-8 labeled as protobuf StringValue, and the read API stringified that Any as JSON. Search now packs names with the same StringValue framing as ReadEntity and returns the plain decoded string. Co-authored-by: Themiya <tkuhemiya@users.noreply.github.com>
|
|
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
No unresolved review issues were identified.
Review effort: Lite
Findings: None
What changed in this PR
Fixes inconsistent search entity-name serialization by using protobuf StringValue framing and returning plain strings from the read API.
Changes:
- Centralizes search-result entity mapping.
- Corrects name packing and unpacking.
- Updates unit and E2E tests.
| File | Description |
|---|---|
opengin/tests/e2e/test_orgchart_test.py |
Updates organization-chart assertions. |
opengin/tests/e2e/basic_read_tests.py |
Updates search assertions. |
opengin/tests/e2e/basic_core_tests.py |
Updates name assertions. |
opengin/read-api/tests/read_api_service_test.bal |
Tests plain-name extraction. |
opengin/read-api/read_api_service.bal |
Unpacks string values. |
opengin/core-api/commons/utils_test.go |
Tests protobuf framing. |
opengin/core-api/cmd/server/utils.go |
Adds corrected entity mapping and name serialization. |
opengin/core-api/cmd/server/utils_test.go |
Tests search-result mapping. |
opengin/core-api/cmd/server/service.go |
Uses the shared mapper for search results. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Fixes #477
Description
Search and get-one-entity both store the same name in Neo4j, for example
Ministry of Health. They serialized it differently, so a decoder written for create/get failed on search.Create and get return a nested object whose protobuf string starts with
0A12. Search returned a JSON string of{typeUrl, hex}whose hex was the raw UTF-8 (4D69) with no protobuf header. The search HTTP field is a string. It should be"Ministry of Health".What changed
ReadEntitiespacks the name withcommons.CreateTimeBasedValue, the same helperReadEntityalready uses.toString()on the wholeAny, so JSONnameis the real text.E2E search tests parsed
namewithjson.loadsand hex-decode because that matched the bug. They now assert the plain string. The old decode would fail after this fix.Notes for reviewers
I moved the core mapping into
entityFromGraphFilterResultso I could unit-test packing without Neo4j. Nothing else calls it. OnlyReadEntitiesand two tests use it. The actual fix is packing withCreateTimeBasedValueinstead of[]byte(name). If you want that left inline in the loop, I can put it back.I added two test files for reasons that are easy to undo:
cmd/server/service_test.gois fully commented out, so search name packing had no live test.commons.ConvertStringToAnyalready existed and had no tests. That helper writes the0A12header.I can drop the helper or merge the tests into existing files if that fits this repo better.
Happy to make any changes and iterate!
How we checked it
Ran MongoDB, Neo4j, Postgres, core, ingestion, and read with Docker Compose.
go test ./...passed, including the new packing tests.testExtractValueAsStringReturnsPlainName.Ministry of Health:0A124D696E6973747279206F66204865616C7468"name": "Ministry of Health"test_search_by_nameand related tests) passed.