Skip to content

chore: migrate to encoding/json/v2 - #6087

Draft
remyleone wants to merge 2 commits into
mainfrom
json_v2
Draft

remyleone wants to merge 2 commits into
mainfrom
json_v2

Conversation

@remyleone

Copy link
Copy Markdown
Member

Community Note

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment to help the community and maintainers prioritize this request.
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for pull request followers and do not help prioritize the request

Relates OR Closes #0000

Release note for CHANGELOG:


@remyleone

Copy link
Copy Markdown
Member Author

blocked by devcontainers/images#1966

@github-actions github-actions Bot added registry Managed Container Registry issues, bugs and feature requests k8s Kubernetes Kapsule issues, bugs and feature requests container Container issues, bugs and feature requests mnq Messaging and queuing issues, bugs and feature requests secret Managed Secret Manager issues, bugs and feature requests labels Aug 31, 2026
@github-actions github-actions Bot added rdb Managed MySQL and PostgreSQL issues, bugs and feature requests redis Managed Redis issues, bugs and feature requests baremetal labels Oct 28, 2026
@github-code-quality

github-code-quality Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Code coverage overview

Languages: Go

Go / cli

main 6fae015 json_v2 d261a65 +/-
59% 59% 0%
View coverage of the 8 most impacted files.
File main 6fae015 json_v2 d261a65 +/-
core/error.go 88% 81% -7%
internal/namesp...cp_resources.go 22% 21% -1%
internal/namesp...lpers_docker.go 65% 64% -1%
core/testing.go 62% 62% 0%
internal/namesp...er/mcp_tools.go 54% 55% +1%
core/printer.go 69% 72% +3%
internal/connect/exec_unix.go 76% 79% +3%
internal/namesp...om_marshaler.go 82% 87% +5%

ℹ️ Calculations represent line coverage. Results may change as calculations are updated.


Updated November 03, 2026 10:47 UTC

@remyleone
remyleone marked this pull request as ready for review November 2, 2026 15:36
Copilot AI balanced review requested due to automatic review settings November 2, 2026 15:36
@remyleone
remyleone requested review from a team as code owners November 2, 2026 15:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Critical serialization regressions drop selected SDK union markers from JSON and MCP responses and bypass custom marshaling for types such as time.Time and netip.Addr, causing them to print as {}.

2 open issues
What changed in this PR

Migrates JSON handling across the Scaleway CLI to encoding/json/v2 and jsontext, covering command output, configuration, integrations, and test utilities.

Changes:

  • Replaces legacy JSON APIs and adds formatting, ordering, and compatibility handling.
  • Updates golden outputs to reflect changed empty-object omission behavior.
  • Adjusts test isolation, cassette selection, and timestamp normalization.
File Description
internal/​qa/​example.go Migrates example JSON handling.
internal/​namespaces/​secret/​v1beta1/​custom_secret_version.go Migrates secret-version JSON handling.
internal/​namespaces/​registry/​v1/​helpers_docker.go Uses v2 formatted writes for Docker configuration.
internal/​namespaces/​registry/​v1/​custom_docker_helper.go Preserves deterministic registry-map output.
internal/​namespaces/​redis/​v1/​testdata/​test-endpoints-single-public-endpoint.golden Removes the empty public-network marker.
internal/​namespaces/​rdb/​v1/​testdata/​test-upgrade-instance-simple.golden Updates upgrade output omission expectations.
internal/​namespaces/​rdb/​v1/​testdata/​test-update-instance-update-instance-tags.golden Updates tag-change output expectations.
internal/​namespaces/​rdb/​v1/​testdata/​test-update-instance-update-instance-name.golden Updates rename output expectations.
internal/​namespaces/​rdb/​v1/​testdata/​test-update-instance-set-a-timezone.golden Updates timezone-change output expectations.
internal/​namespaces/​rdb/​v1/​testdata/​test-update-instance-modify3-settings+-add-a-new-one.golden Updates multi-setting output expectations.
internal/​namespaces/​rdb/​v1/​testdata/​test-update-instance-modify-default-work-mem-from4-to8mb.golden Updates memory-setting output expectations.
internal/​namespaces/​rdb/​v1/​testdata/​test-list-instance-simple.golden Removes empty load-balancer markers from list output.
internal/​namespaces/​rdb/​v1/​testdata/​test-get-instance-simple.golden Removes empty load-balancer markers from instance output.
internal/​namespaces/​rdb/​v1/​testdata/​test-endpoint-list-multiple-endpoints.golden Updates endpoint-list omission expectations.
internal/​namespaces/​rdb/​v1/​testdata/​test-endpoint-get-public.golden Removes the empty public-endpoint marker.
internal/​namespaces/​rdb/​v1/​testdata/​test-endpoint-create-public.golden Updates public-endpoint creation output.
internal/​namespaces/​rdb/​v1/​testdata/​test-endpoint-create-private-static.golden Updates static private-endpoint creation output.
internal/​namespaces/​rdb/​v1/​testdata/​test-endpoint-create-private-ipam.golden Updates IPAM private-endpoint creation output.
internal/​namespaces/​rdb/​v1/​testdata/​test-create-instance-simple.golden Updates instance-creation omission expectations.
internal/​namespaces/​rdb/​v1/​testdata/​test-create-instance-init-endpoints-with-public-and-static-private-endpoint.golden Updates mixed static-endpoint creation output.
internal/​namespaces/​rdb/​v1/​testdata/​test-create-instance-init-endpoints-with-public-and-ipam-private-endpoint.golden Updates mixed IPAM-endpoint creation output.
internal/​namespaces/​rdb/​v1/​testdata/​test-clone-instance-simple.golden Updates clone output omission expectations.
internal/​namespaces/​object/​v1/​s3configfile.go Migrates S3 configuration JSON handling.
internal/​namespaces/​object/​v1/​custom_marshaler.go Adapts formatted output and AWS metadata serialization.
internal/​namespaces/​object/​v1/​custom_bucket_policy.go Formats policy JSON with jsontext.Value.
internal/​namespaces/​object/​v1/​custom_bucket_lifecycle.go Migrates lifecycle JSON handling.
internal/​namespaces/​object/​v1/​custom_bucket_cors.go Migrates CORS JSON handling.
internal/​namespaces/​mnq/​v1beta1/​custom_nats_helpers.go Migrates NATS helper JSON handling.
internal/​namespaces/​mcp/​server/​mcp_tools.go Uses v2 for formatted tool results.
internal/​namespaces/​mcp/​server/​mcp_tools_test.go Migrates tool metadata serialization tests.
internal/​namespaces/​mcp/​server/​mcp_resources.go Uses v2 for formatted resource results.
internal/​namespaces/​login/​login.go Migrates login JSON handling.
internal/​namespaces/​k8s/​v1/​custom_execcredentials.go Uses v2 for formatted credentials output.
internal/​namespaces/​k8s/​v1/​custom_execcredentials_test.go Migrates credentials JSON tests.
internal/​namespaces/​inference/​v1/​testdata/​test-deployment-create-simple-deployment.golden Removes the empty public-network marker.
internal/​namespaces/​inference/​v1/​testdata/​test-deployment-create-deployment-with-wait-flag.golden Updates waited deployment output expectations.
internal/​namespaces/​inference/​v1/​testdata/​test-create-deployment-private-endpoint-create-deployment-private-endpoint.golden Updates mixed-endpoint deployment output.
internal/​namespaces/​inference/​v1/​custom_serverless_models.go Decodes model responses with UnmarshalRead.
internal/​namespaces/​container/​v1/​testdata/​test-update-container-simple.golden Removes the empty TCP probe marker.
internal/​namespaces/​container/​v1/​testdata/​test-update-container-registry-image.golden Updates image-change probe output expectations.
internal/​namespaces/​container/​v1/​testdata/​test-create-container-simple.golden Updates container-creation probe output expectations.
internal/​namespaces/​container/​v1/​custom_logs.go Migrates container-log JSON handling.
internal/​namespaces/​container/​v1/​custom_deploy.go Migrates deployment JSON handling.
internal/​namespaces/​baremetal/​v1/​testdata/​test-baremetal-list-offer-simple.golden Removes empty option-type markers from offer listings.
internal/​namespaces/​baremetal/​v1/​testdata/​test-baremetal-get-offer-simple.golden Removes empty option-type markers from offer details.
internal/​editor/​marshal.go Uses v2 for formatted editor JSON.
core/​testing.go Migrates JSON and adjusts test isolation and normalization.
core/​result.go Migrates result JSON handling.
core/​printer.go Adds v2 output options and empty-struct fallback.
core/​human/​marshal_func.go Migrates JSON use in human-readable formatting.
core/​example.go Migrates command-example JSON handling.
core/​error.go Adds explicit error JSON compatibility handling.
core/​build_info.go Migrates build-information JSON handling.

Review effort: Balanced

Comment thread core/printer.go
Comment on lines +288 to +292
opts := []json.Options{
json.Deterministic(true),
json.FormatNilSliceAsNull(true),
json.FormatNilMapAsNull(true),
jsontext.EscapeForHTML(true),
Comment thread core/printer.go
Comment on lines +307 to +308
if noExportedFields(data) {
_, err := writer.Write([]byte("{}\n"))
@remyleone
remyleone marked this pull request as draft November 3, 2026 10:19
@github-actions github-actions Bot removed rdb Managed MySQL and PostgreSQL issues, bugs and feature requests redis Managed Redis issues, bugs and feature requests baremetal labels Nov 3, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

container Container issues, bugs and feature requests k8s Kubernetes Kapsule issues, bugs and feature requests mnq Messaging and queuing issues, bugs and feature requests registry Managed Container Registry issues, bugs and feature requests secret Managed Secret Manager issues, bugs and feature requests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants