Skip to content

fix(async): quote the key in the get not-found error - #12

Merged
josuegiron merged 2 commits into
masterfrom
fix/async-get-quote-key
Nov 21, 2026
Merged

josuegiron merged 2 commits into
masterfrom
fix/async-get-quote-key

Conversation

@josuegiron

Copy link
Copy Markdown
Member

Container.Get returned container: item not found, key (%v) with the key written verbatim. Keys may come from untrusted input (the package documents TrySet for that case), so a key with line breaks or other control characters ended up raw in error text that callers log.

The key is now rendered with fmt.Sprint and quoted with %q: key ("a\nb"), key ("65") (quoting the string form avoids rune literals for integer keys). The nil-map branch was folded into the single not-found branch, since a lookup in a nil map already reports a missing key.

  • Test: TestContainerGetMissingKeyQuotesKey (newline, CR/ESC and integer keys; fails before the change).
  • README Compatibility section notes the new text.
  • Local: gofmt -l . empty, go vet ./..., go test -race ./..., govulncheck ./... clean.

Behavior note for release notes: the error text changes (the key is quoted).

🤖 Generated with Claude Code

@josuegiron
josuegiron merged commit 7bedf1b into master Nov 21, 2026
2 checks passed
@josuegiron
josuegiron deleted the fix/async-get-quote-key branch November 21, 2026 20:19
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.

1 participant