Repository navigation
fix: decode named byte containers without panicking - #214
Open
DeviousCardi wants to merge 1 commit into
Open
DeviousCardi wants to merge 1 commit into
DeviousCardi wants to merge 1 commit into
Conversation
Use reflection byte accessors instead of concrete byte type assertions in weak string conversions. Assisted-by: Codex
DeviousCardi
marked this pull request as ready for review
October 18, 2026 18:36
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Weak string conversion currently panics for defined byte slice types and for slices or arrays with a defined uint8 element type. For example,
type Octet uint8; var out string; WeakDecode([]Octet{'f', 'o', 'o'}, &out)panics instead of returning"foo".WeaklyTypedHookalso panics on defined byte slices.Use
reflect.Value.Bytesfor slices andUintfor array elements, matching the existing uint8-kind checks. Ordinary byte slices retain the existing conversion path without an extra buffer allocation. Add regression coverage for defined slice and element types, arrays, nil and empty containers, and binary bytes, plus both defined-slice cases in the hook tests.Validation (Go 1.26.9, linux/amd64):
go test -race -shuffle=on ./...passed.go vet ./...passed.git diff --checkpassed.This bug was found independently; searches of existing issues and pull requests found no matching report or active fix.
Written by Codex.