add json tags to PackageInfo struct and tests - #40
Conversation
toolchain would not download with go get Changelog: fixed
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. WalkthroughThis PR updates the Go module go version in Changes
Sequence Diagram(s)(omitted — changes are structural/serialization-only and do not modify runtime control flow) Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
🧰 Additional context used🧬 Code graph analysis (1)manager/packageinfo.go (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
🔇 Additional comments (1)
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 |
Summary of ChangesHello @aijanai, 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 primarily focuses on improving the JSON serialization of the Highlights
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.
Caution
Changes requested ❌
Reviewed everything up to 0874811 in 1 minute and 45 seconds. Click for details.
- Reviewed
90lines of code in3files - Skipped
0files when reviewing. - Skipped posting
1draft comments. View those below. - Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. go.mod:3
- Draft comment:
Using 'go 1.23.0' instead of '1.23' meets the toolchain download requirement. Ensure that this format is consistently documented across the project. - Reason this comment was not posted:
Confidence changes required:0%<= threshold50%None
Workflow ID: wflow_6PplkVkFl0VMFQqn
You can customize by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.
There was a problem hiding this comment.
Code Review
This pull request correctly adds JSON tags to the PackageInfo struct and fixes the Go version in go.mod. The addition of tests for the JSON tags is a great initiative. I've provided a couple of suggestions to improve the implementation. One suggestion is to use omitempty in the JSON tags to create a more compact JSON output for optional fields. The other is a rewrite of the new test to make it more robust and correct, as the current version has a few issues.
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
manager/packageinfo_test.go (1)
17-18: Consider strengthening the test validation.The current test only checks if tag strings appear anywhere in the JSON output. A more robust approach would verify they appear as actual JSON keys.
Consider using
json.Unmarshalinto amap[string]interface{}to verify the exact keys:func TestPackageInfoJsonTag(t *testing.T) { testPackage := PackageInfo{} jsonAsByte, err := json.Marshal(testPackage) if err != nil { t.Fatalf("Failed to marshal PackageInfo: %v", err) } var jsonMap map[string]interface{} if err := json.Unmarshal(jsonAsByte, &jsonMap); err != nil { t.Fatalf("Failed to unmarshal JSON: %v", err) } expectedKeys := []string{"name", "version", "new_version", "status", "category", "arch", "package_manager", "additional_data"} for _, key := range expectedKeys { if _, exists := jsonMap[key]; !exists { t.Errorf("Expected key '%s' not found in JSON: %v", key, jsonMap) } } }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
go.mod(1 hunks)manager/packageinfo.go(1 hunks)manager/packageinfo_test.go(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
manager/packageinfo.go (1)
interface.go (1)
PackageManager(6-72)
🔇 Additional comments (2)
manager/packageinfo.go (1)
55-88: LGTM! JSON tags are correctly applied.All eight exported fields now have appropriate JSON struct tags using consistent snake_case naming. This improves JSON serialization consistency and is a good practice for cross-language data interchange. The changes are non-breaking and only affect how the struct is serialized to JSON.
go.mod (1)
3-3: Go version format update verified and approved.The change from
go 1.23togo 1.23.0is valid and properly recognized by Go's module system. Verification confirmsgo mod verifypasses successfully with the updated format, demonstrating that the explicit patch version is supported by Go tooling.
checks for tag usage Changelog: added
Changelog: added
|
@bluet at your convenience :) |
There was a problem hiding this comment.
Pull Request Overview
This PR adds JSON serialization tags to the PackageInfo struct to ensure proper JSON field naming (snake_case) and adds corresponding tests to verify the tags are correctly applied. It also fixes the Go version specification in go.mod.
Key Changes
- Added JSON tags with snake_case naming to all
PackageInfostruct fields - Created comprehensive test to validate JSON serialization and field presence
- Fixed Go version from
1.23to1.23.0for proper toolchain download
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| manager/packageinfo.go | Added JSON tags to PackageInfo struct fields with snake_case naming and omitempty for optional fields |
| manager/packageinfo_test.go | Added new test TestPackageInfoJsonTag to verify JSON tag presence and correct serialization |
| go.mod | Fixed Go version specification from 1.23 to 1.23.0 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
Thanks for this @aijanai — and apologies for the 6-month delay reviewing this. The PR is exactly the kind of clean, focused contribution we want: snake_case JSON tags following Go community convention, sensible Acknowledging this is a breaking change for any consumer parsing JSON output (PascalCase → snake_case), but pre-v1.0.0 is exactly the right window for it, and snake_case is the right long-term convention. Squash-merging now. Also crediting the |
…67) * fix(apt): honor DryRun in Clean() to prevent silent destructive ops Previously, Clean() executed `apt autoclean` regardless of the DryRun option, silently defeating the safety mechanism users expect from dry-run mode. The YUM/Snap/Flatpak Clean implementations on main already honored DryRun; APT now matches that behavior. Add the early-return guard immediately after nil-opts defaulting (matching the pattern at yum/yum.go:467, snap/snap.go:295, flatpak/flatpak.go:300). Move context creation below the guard so the DryRun path doesn't allocate an unused context. Regression tests cover three contracts: - Clean(DryRun=true) makes zero underlying command calls - Clean(DryRun=false) does invoke `apt autoclean` (guards against the fix being implemented as a blanket no-op) - Clean(nil) preserves the existing nil-opts default behavior This is security-relevant: a user testing with `--dry-run` on shared or production hosts could trigger cache cleanup unexpectedly. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> * ci(docker): make test failures propagate + harden test-all service The compose test entrypoints used `bash -c` with `&&` chains and trailing `|| true` on fixture-generation steps. Due to bash operator precedence, the trailing `|| true` caught failures from earlier in the chain — including `go test` itself — letting failed tests pass CI silently while only the (allowed-to-fail) fixture-generation step appeared to succeed. Switch to `bash -ec` with explicit `;` separators for required steps: - Required commands (go test, apt update) abort the script on non-zero exit (set -e via -e flag) - Fixture-generation lines retain `|| true` so they remain individually allowed to fail - Statements use `;` instead of `&&` so set -e can actually trigger on intermediate failures (set -e doesn't apply to commands inside `&&` lists except the final command) Applied to ubuntu-apt-test, rockylinux-yum-test, almalinux-yum-test. Defense-in-depth on the test-all aggregator service: - read_only: true (it only runs an echo, no writes needed) - security_opt: [no-new-privileges:true] The required services (apt/yum tests) need write access for fixture generation and don't get these constraints. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> * docs(changelog): add v0.1.7 entry Document the APT Clean DryRun safety fix, the docker-compose exit code propagation fix, the test-all defense-in-depth hardening, the PackageInfo JSON tags change (#40), and the go.mod toolchain version fix (#40). Also picks up pre-commit-mandated cleanup of pre-existing trailing whitespace and missing trailing newline. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> * ci(docker): apply review feedback on test-all hardening Three small follow-ups to the test-all aggregator service from PR #67 review: - depends_on switched to long-form with `condition: service_completed_successfully` for each dependent service. The short form only waited for dependents to *start*, so test-all's `echo` could finish in milliseconds and abort the compose run (--abort-on-container-exit) before the real tests reported failure. Same class of CI-honesty bug the bash -ec change in this same release fixes one layer up. (gemini-code-assist HIGH) - /workspace bind mount made read-only (`:ro`). test-all only runs an echo, so the mount doesn't need write access. Defense-in-depth consistent with the existing read_only and security_opt. (CodeRabbit) - Quoted "no-new-privileges:true" to eliminate YAML-parser ambiguity around `key:value` parsing while preserving Docker's documented form. (gemini-code-assist SECURITY-MEDIUM) Verified via `docker compose config`: depends_on shows long-form with condition: service_completed_successfully; read_only: true on the bind mount; security_opt preserves the documented form. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> * ci(docker): switch to --abort-on-container-failure to stop killing slow tests `--abort-on-container-exit` aborts the compose run when ANY container exits — success or failure. With multi-service runs (`make test-docker`, `make test-docker-all`), the FASTEST test container's success would kill the slower siblings mid-test, masking failures and skipping most of the matrix. Long-form depends_on on `test-all` from the prior commit only addressed the test-all → dependents race; the test containers race against each other was still there. Switch to `--abort-on-container-failure` (Docker Compose v2.12+) which aborts only when a container exits non-zero. Now multi-service runs wait for all test containers to finish, fail fast on actual failure, and surface real CI signal. Applied uniformly across test-docker, test-docker-{ubuntu,rocky,alma}, test-fixtures, and the commented-out future targets. Catch from chatgpt-codex-connector P1 review on PR #67. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> * ci(docker): use Compose v2 syntax (`docker compose`) for new flag Docker Compose v1 (`docker-compose`, the standalone Python binary) was EOL'd June 2023 and does not support `--abort-on-container-failure` introduced in the prior commit. With the Makefile invoking the legacy hyphenated form, environments still using v1 would have all the `make test-docker*` targets fail before any tests run. Switch all 8 invocations from `docker-compose ...` to `docker compose ...` (v2 plugin / standalone v2 binary). Filenames containing `docker-compose` (e.g. `docker-compose.test.yml`) are unchanged. Verified locally: `make test-docker-ubuntu` exits 0 with the v2 command. Catch from chatgpt-codex-connector P2 review on PR #67. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>



json should have low case, underscore separated names.
Add tests that verify that the tags have been used
Fix a missing
.0in the go version, that prevented successful download of toolchainChangelog: added
Important
Add JSON tags to
PackageInfostruct and tests to verify serialization, and fix Go version ingo.mod.PackageInfostruct fields inpackageinfo.gofor proper serialization.TestPackageInfoJsonTaginpackageinfo_test.goto verify JSON tags are applied.go.modfrom1.23to1.23.0.This description was created by
for 0874811. You can customize this summary. It will automatically update as commits are pushed.
Summary by CodeRabbit
Improvements
Chores
Tests