Skip to content

Update module github.com/fxamacker/cbor/v2 to v2.10.0 - #224

Open
renovate[bot] wants to merge 1 commit into
mainfrom
renovate/github.com-fxamacker-cbor-v2-2.x
Open

renovate[bot] wants to merge 1 commit into
mainfrom
renovate/github.com-fxamacker-cbor-v2-2.x

Conversation

@renovate

@renovate renovate Bot commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

Note

This PR body was truncated due to platform limits.

This PR contains the following updates:

Package Change Age Confidence
github.com/fxamacker/cbor/v2 v2.2.0 → v2.10.0 age confidence

Release Notes

fxamacker/cbor (github.com/fxamacker/cbor/v2)

v2.10.0

Compare Source

v2.10 speeds up encoding by up to 2.88× and decoding by up to 1.87× with zero memory regressions (B/op, allocs/op), reduces memory use, adds the toindefarray struct tag option, and fixes bugs. The Contributing Guidelines, Security Policy, and templates were extensively updated.

Encoding sorted nested maps of dynamic JSON-like data to CBOR drops from 70 allocs/op to 1 and from 7.2 KiB/op to 4.0 KiB/op in the benchmarks below. Encoding time.Time, big.Int, Tag and Marshaler values, and decoding into time.Time, big.Int and Tag, use 1 to 2 fewer allocs/op (20% to 50% fewer).

This release does not use Go's unsafe package. Performance in user apps depends on configuration and data.

Tests were refactored and coverage increased to 97.7%. Fuzz tests (not yet public) were also extended. Internal checklists and procedures were updated to reduce potential mistakes.

Performance and Benchmarks

Across all 215 benchmarks, there are zero memory regressions (B/op, allocs/op). Just one benchmark showed a speed dip: Marshal/struct_many_flds_all_omitempty_all_empty/map is ~4-5% slower, but only when a struct has 32 fields that are both omitzero and empty (same scenario with an 8-field struct is now faster).

Benchmarks ran with Go 1.26.10 on linux/amd64 (benchstat n=10, p=0.000):

  • CBOR Speedup by Data Type: groups of different benchmarks summarized per row
  • CBOR Encoding Reflection-Free Speedup: dynamic JSON-like data types and common types
CBOR Speedup by Data Type
Unmarshal Speedup ΔSec/op
Single values (bool, int, float, byte string, text string) 1.10× to 1.51×¹ -8.87% to -33.92%¹
Epoch time, bignum, other tags 1.18× to 1.64× -15.33% to -38.91%
Arrays and maps to non-struct 1.33× to 1.87× -24.63% to -46.49%
Arrays and maps to structs 1.06× to 1.52× -5.46% to -34.40%
Real-world (COSE, CWT, SenML, WebAuthn) 1.35× to 1.64× -26.06% to -39.19%

¹ 2.54× speedup (-60.64%) when decoding into a named []byte type that has methods.

Marshal Speedup ΔSec/op
Single values (bool, int, float, byte slice, string) 1.32× to 1.55× -24.49% to -35.41%
time.Time, big.Int, Tag, Marshaler² 1.15× to 1.63× -12.94% to -38.84%
Slices and maps 1.35× to 2.88× -25.97% to -65.26%
Structs 1.57× to 2.17× -36.37% to -53.96%
Structs with omitempty fields 0.95׳ to 1.35× +5.01%³ to -25.96%
Real-world (COSE, CWT, SenML, WebAuthn) 1.12× to 1.33× -10.66% to -24.77%

² For addressable values (reached through a pointer, struct field, slice element or map value).

³ Only when every field is omitempty and empty: 7.6 ns slower for a 32-field struct, 2.37 ns faster for an 8-field struct. This is the only performance regression in all 215 benchmarks.

CBOR Encoding Reflection-Free Speedup

PR #​870 optimized common types: int, int64, uint, uint64, float64, bool, string, nil, []byte, []any, map[any]any, map[string]any, and map[string]string.

Marshal Benchmark
v2.9.6 → v2.10
Speedup Time
ΔSec/op
Memory
ΔB/op
Memory
ΔAllocs/op
[]any 2.50× -607.5 ns (-60.03%) - -
map[string]any 2.60× -821.9 ns (-61.47%) - -
map[string]string 2.59× -335.9 ns (-61.34%) - -
nested_map[any]any 2.88× -16.542 µs (-65.26%) - -
nested_map[string]any 2.78× -14.201 µs (-64.01%) - -
nested_map[any]any, bw_lex 2.53× -22.36 µs (-60.54%) -3314 (-44.72%) -69 (-98.57%)
nested_map[string]any, bw_lex 2.41× -19.52 µs (-58.54%) -3323 (-44.79%) -69 (-98.57%)
  • bw_lex = SortBytewiseLexical. Memory improvements are from #​774 and #​860.

Upgrade Notes

  • Go 1.24 or newer is required (#​773). All tests (97.7% coverage) pass on Go 1.24-1.27.
  • Pointer-receiver marshal methods (user-implemented methods) are called on the original value instead of a copy when the value is addressable (#​866).
  • Marshal configured to use TagsForbidden returns an error for a big.Int outside [-2^64, 2^64-1], and EncMode creation returns an error for settings that would emit tags if TagsForbidden is also set (#​868).
  • Decoder advances past well-formed data items rejected by DecOptions value or serialization restrictions (e.g. NaN, IndefLength), and Skip skips them without an error (#​872).
  • Marshal configured to emit text-based time returns an error for time.Time outside RFC 3339 limits (#​873).

TinyGo (experimental)

TinyGo support for v2.10.0 is available in tag tinygo-beta/v2.10.0-tinygo0.42 (branch feature/cbor-tinygo-beta). It requires TinyGo 0.42.0 or newer. It is experimental and not fuzz tested. For details, see TinyGo (https://github.com/fxamacker/cbor#tinygo) in the README.

What's Changed

⭐ Features
  • feat: add toindefarray struct tag option for CBOR indefinite-length arrays by @​tdnguyenND in #​770
🚀 Optimizations
🛠 Improvements
🐞 Bug Fixes
🧪 Testing
📖 Documentation
📖 Contributing Guidelines, Security Policy, and Templates
CI / GitHub Actions
🔎 Details
Other Changes
Ported from release-2.9

Already released in v2.9.3 through v2.9.6.

🔎 Details
Dependabot Updates
🔎 Details

New Contributors

Full Changelog: fxamacker/cbor@v2.9.6...v2.10.0

v2.9.6

Compare Source

v2.9.6 fixes 12 bugs, including an important fix for apps that decode CBOR maps into Go maps, and has one behavior change. API is unchanged but more errors are detected.

Most of these bugs were identified while improving tests and reviewing code for an upcoming release.

Tests and fuzz tests were extended.

Upgrading to v2.9.6 from all prior versions is recommended.

🐞 Important Fix

For use cases outside the "not affected by this bug" list below, decoding a CBOR null or undefined map key or value (including 55799(null)) into a Go map whose key or value type is of bool, integer, float, or string kind kept the previous map entry's key or value (instead of the zero value). See PR #​855 for details.

Not affected by this bug:

  • Decoding data this codec encoded from the same Go map type, because this codec does not encode to CBOR null from Go values of bool, integer, float, or string kind.
  • Apps that don't decode a CBOR null or undefined map key or value into a Go map whose key or value type is of bool, integer, float, or string kind.
  • Decoding CBOR maps into structs (struct fields of map type follow the bullet above).
  • Decoding CBOR maps into map[any]any, and into any (with unchanged DefaultMapType).
⚠️ Behavior change

Decoding CBOR null or undefined into an interface that holds a value now sets it to nil, matching encoding/json (v1 and v2). Previously, the interface kept its value (PR #​827), which was not the intended behavior.

🛠 Bug fixes

Some of these bugs could only be triggered by incorrect usage in user apps, such as invalid struct tags or an unsupported DefaultByteStringType setting, etc. None of these bugs were reported by a project affected by them.

Decoding
Encoding
  • Fix encoding self-referencing types by @​fxamacker in #​833
  • Fix panic encoding marshaler of unsupported underlying types by @​fxamacker in #​834
  • Fix omitzero panic encoding struct field of unsupported underlying types implementing marshaler by @​fxamacker in #​835
  • Fix encoding TimeUnixMicro outside 1677 to 2262 by @​fxamacker in #​837
    • Encoded output also changes for some times within one second of either end of that range.
  • Reject encoding time.Time when Go formats wrong year by @​fxamacker in #​838
📖 Documentation

Full Changelog: fxamacker/cbor@v2.9.4...v2.9.6

v2.9.5

Compare Source

This version was tagged from the default branch by mistake and is retracted.

Use v2.9.6 (https://github.com/fxamacker/cbor/releases/tag/v2.9.6) instead.

v2.9.4

Compare Source

This release fixes potential panics when decoding a CBOR map whose key decodes to an uncomparable Go value under certain conditions.

Not affected: user apps that don't register tag types and don't use map key types that are either named empty interfaces (e.g. type MyAny any) or contain interfaces.

These potential panics can be encountered when one of these two conditions is met:

  • user application registers a tag type (via TagSet interface) that is an array or struct with uncomparable or interface{} element or field type, or
  • user application specifies a destination Go map whose key type is a named empty interface type or a type containing an interface.

This was identified while improving tests and reviewing code for an upcoming release.

Tests and fuzz tests were extended to cover this bug.

Upgrading to v2.9.4 is recommended.

What's Changed

Full Changelog: fxamacker/cbor@v2.9.3...v2.9.4

v2.9.3

Compare Source

This release fixes a potential panic when decoding into a time.Time from a CBOR byte string, map, or array under certain conditions.

Not affected: standard CBOR time data (RFC 8949 tag 0 or tag 1), and decoders configured with timeTag = DecTagRequired.

Upgrading to v2.9.3 is recommended.

The panic stack trace was publicly reported on 2026-08-17, and the fix was released the same day. Fuzz testing was extended to cover this class of bug, and fuzzing of v2.9.3 is ongoing.

What's Changed

  • Skip data item when decoding to time.Time fails under certain conditions by @​fxamacker in #​803

Full Changelog: fxamacker/cbor@v2.9.2...v2.9.3

v2.9.2

Compare Source

This release refactors and hardens the streaming encoder by adding stricter checks for encoding CBOR indefinite-length data. Other changes include minor bugfixes, defensive checks, and more tests.

Projects that don't use CBOR indefinite-length data may also want to upgrade (summary of prior releases).

The stricter checks in the encoder prevent improper use of the library and bad inputs from producing malformed CBOR indefinite-length data that would be rejected by the decoder.

This release passed fuzz tests (billions of execs) and it is production quality.

What's Changed

  • Reject encoding indefinite-length map with odd item count by @​fxamacker in #​764
  • Reject encoding indefinite-length data item as a chunk inside indefinite-length byte string or text string by @​fxamacker in #​765
  • Make TagSet.Remove a no-op when contentType is nil by @​fxamacker in #​766
  • Refactor indefinite-length encoding and improve chunk validation during encoding by @​fxamacker in #​767
  • Add more tests, fix a nit in unreachable panic message, update docs & ci by @​fxamacker in #​768
CI / GitHub Actions and Docs
🔎 Details...

Full Changelog: fxamacker/cbor@v2.9.1...v2.9.2

v2.9.1

Compare Source

This release includes important bugfixes, defensive checks, improved code quality, and more tests. Although not public, the fuzzer was also improved by adding more fuzz tests.

🐞 Bug fixes related to the keyasint feature

These changes only affect Go struct fields tagged with keyasint:

  • [Decoding] Reject integer keys that exceed math.MaxInt64 when decoding CBOR map to a struct with keyasint field (PR #​757)
  • [Decoding] Prevent string representation of an integer key from matching the struct field tagged by keyasint (PR #​757)
  • [Encoding & Decoding] Deduplicate struct fields with the same normalized keyasint tag values (PR #​757)
🐞 Other bug fixes and defensive checks

Some of the bugs fixed are related to decoding extreme values that cannot be encoded with this library. For example, the decoder checks if epoch time encoded as CBOR float value representing hundreds of billions of years overflows int64(seconds).

NOTE: It is generally good practice to avoid using floating point to store epoch time (even when not using CBOR).

  • [Decoding] Reject decoding epoch time encoded as floats that overflow int64 (PR #​753)
  • [Encoding] Return a cloned slice for an empty RawMessage from RawMessage.MarshalCBOR (PR #​753)
  • [Encoding] Reject encoding nil inside indefinite-length strings (PR #​750)
  • [Diagnostic] Accept valid U+FFFD replacement character (PR #​753)

What's Changed

CI / GitHub Actions and Docs
🔎 Details...

New Contributors

Full Changelog: fxamacker/cbor@v2.9.0...v2.9.1

v2.9.0

Compare Source

v2.9.0 adds new features, refactors tests, and improves docs. New features improve interoperability/transcoding between CBOR & JSON.

v2.9.0 passed fuzz tests and is production quality. However, the new TextUnmarshaler feature will continue being fuzz tested a bit longer due to recent changes. The recent changes are limited and don't affect other parts of the codec that passed ~2 billion execs fuzzing.

What's Changed

Docs

CI

🔎 Details

Special Thanks

Many thanks to @​benluddy for adding these new features! 🎉

  • Add opt-in support for encoding.TextMarshaler and encoding.TextUnmarshaler to encode and decode from CBOR text string.
  • Add opt-in support for json.Marshaler and json.Unmarshaler via user-provided transcoding function.

New Contributors

[!IMPORTANT]
✂ PR body was truncated to here.


Configuration

📅 Schedule: (UTC)

  • Branch creation
    • "on the first day of the month"
  • Automerge
    • At any time (no schedule defined)

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about this update again.


  • If you want to rebase/retry this PR, check this box

This PR was generated by Mend Renovate. View the repository job log.

@renovate renovate Bot changed the title Update module github.com/fxamacker/cbor/v2 to v2.9.3 Update module github.com/fxamacker/cbor/v2 to v2.9.3 - autoclosed Sep 1, 2026
@renovate renovate Bot closed this Sep 1, 2026
@renovate
renovate Bot deleted the renovate/github.com-fxamacker-cbor-v2-2.x branch September 1, 2026 10:53
@renovate renovate Bot changed the title Update module github.com/fxamacker/cbor/v2 to v2.9.3 - autoclosed Update module github.com/fxamacker/cbor/v2 to v2.9.3 Sep 1, 2026
@renovate renovate Bot reopened this Sep 1, 2026
@renovate
renovate Bot force-pushed the renovate/github.com-fxamacker-cbor-v2-2.x branch 2 times, most recently from 79e6060 to 255e7fa Compare September 1, 2026 17:16
@renovate
renovate Bot force-pushed the renovate/github.com-fxamacker-cbor-v2-2.x branch from 255e7fa to b4a8b08 Compare September 14, 2026 21:50
@renovate renovate Bot changed the title Update module github.com/fxamacker/cbor/v2 to v2.9.3 Update module github.com/fxamacker/cbor/v2 to v2.9.4 Sep 14, 2026
@renovate
renovate Bot force-pushed the renovate/github.com-fxamacker-cbor-v2-2.x branch from b4a8b08 to 926fcc3 Compare October 7, 2026 02:46
@renovate renovate Bot changed the title Update module github.com/fxamacker/cbor/v2 to v2.9.4 Update module github.com/fxamacker/cbor/v2 to v2.9.6 Oct 7, 2026
@renovate
renovate Bot force-pushed the renovate/github.com-fxamacker-cbor-v2-2.x branch from 926fcc3 to ed0369d Compare October 28, 2026 16:55
@renovate renovate Bot changed the title Update module github.com/fxamacker/cbor/v2 to v2.9.6 Update module github.com/fxamacker/cbor/v2 to v2.10.0 Oct 28, 2026
@renovate

renovate Bot commented Oct 28, 2026

Copy link
Copy Markdown
Contributor Author

ℹ️ Artifact update notice

File name: go.mod

In order to perform the update(s) described in the table above, Renovate ran the go get command, which resulted in the following additional change(s):

  • The go directive was updated for compatibility reasons

Details:

Package Change
go 1.13 -> 1.24

@sonarqubecloud

Copy link
Copy Markdown

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants