fix: preserve brackets in vehicle crew data to fix side coloring#90
fix: preserve brackets in vehicle crew data to fix side coloring#90
Conversation
The handler was stripping brackets from crew arrays received from the game (e.g. "[20,21]" → "20,21"). During JSON export, json.Unmarshal would then fail for multi-crew vehicles, producing empty crew arrays. Single-crew vehicles exported a scalar instead of a one-element array. This caused the web frontend to show all vehicles without side colors, since it derives vehicle side from the first crew member's faction. - Stop stripping brackets in LogVehicleState handler - Parse crew as JSON in legacy DB export path (main.go) - Add regression tests at handler, builder, and integration levels
Summary of ChangesHello @fank, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request resolves a critical data integrity issue affecting vehicle crew information. Previously, the system was inadvertently stripping JSON array brackets from crew data, which led to parsing failures during export and consequently, incorrect or missing vehicle side colors in the user interface. The changes ensure that crew data is stored and processed as valid JSON arrays throughout the application's lifecycle, thereby restoring proper functionality and visual representation. Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request fixes a bug where brackets were stripped from vehicle crew data, leading to JSON parsing errors during export. The changes correctly preserve the brackets in the handler and add JSON parsing logic in the legacy DB export path to align with the memory export path. The new unit and integration tests are well-written and thoroughly cover the fix for various crew data formats. I've suggested a minor simplification to the new JSON parsing logic for improved conciseness.
json.Unmarshal already returns an error for empty strings, so the explicit empty-string guard is unnecessary.
Merging this branch will increase overall coverage
Coverage by fileChanged files (no unit tests)
Please note that the "Total", "Covered", and "Missed" counts above refer to code statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code. Changed unit test files
|
Summary
[20,21]) had their brackets stripped by the handler, storing20,21insteadjson.Unmarshal("20,21")failed for multi-crew vehicles → empty crew[]in output108) instead of an array ([108])Root cause:
handlers.goline 546-548 stripped[and]from crew data before storingFix:
LogVehicleState— store the raw JSON array string as received from the gamemain.go) to match the memory export pathTest plan
TestLogVehicleState_CrewPreservesBrackets— handler preserves brackets for multi-crew, single-crew, empty, and large arraysTestBuildWithVehicleCrewIDArray— builder correctly parses[20,21],[20], and[]crew formatsTestVehicleCrewExportIntegration— full pipeline (memory backend → builder → JSON file → JSON parse) with crew array round-tripgo test ./...)