Skip to content

fix(stdlib): Return string from base64_decode - #6791

Open
jplitza wants to merge 1 commit into
grafana:mainfrom
jplitza:patch-1
Open

fix(stdlib): Return string from base64_decode#6791
jplitza wants to merge 1 commit into
grafana:mainfrom
jplitza:patch-1

Conversation

@jplitza

@jplitza jplitza commented Jul 30, 2026

Copy link
Copy Markdown

Brief description of Pull Request

This changes the return type of the encoding.from_base64() and encoding.from_URLbase64() functions in the stdlib from []byte to string.

Pull Request Details

Previously, encoding.from_base64() returned []byte, which could not be cast to secret and hence could not be used in places where a secret was expected. The error was:

encoding.from_base64(...) should be capsule, got array

Converting bytes to a string needs to assume an encoding. Go should use UTF-8 here. This conversion happened implicitly before the change whenever the result was used as string.

Issue(s) fixed by this Pull Request

Fixes #5450

Notes to the Reviewer

PR Checklist

  • Documentation added
  • Tests updated
  • Config converters updated
  • This pull request was substantially generated with AI assistance (see the GenAI policy)

@jplitza
jplitza requested a review from a team as a code owner July 30, 2026 07:32
@github-actions

github-actions Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Signed commits report

All 1 commit between main and patch-1 have verified signatures. ✅

Previously []byte was returned, which could not be cast to secret.

Fixes grafana#5450
@jplitza jplitza changed the title fix(stdlib): return string from base64_decode fix(stdlib): Return string from base64_decode Aug 4, 2026
@jplitza

jplitza commented Aug 4, 2026

Copy link
Copy Markdown
Author

I uppercased the PR title, but I fail to see how this failing test has anything to do with my changes or how to fix it:

--- FAIL: TestLokiAzureEventHubs (2.33s)
    loki_azure_event_hubs_test.go:39: 
        	Error Trace:	/home/runner/work/alloy/alloy/integration-tests/docker/tests/loki-azure-event-hubs/loki_azure_event_hubs_test.go:39
        	Error:      	Received unexpected error:
        	            	failed to send message to topic "test1": kafka server: Tried to send a message to a replica that is not the leader for some partition. Your metadata is out of date
        	Test:       	TestLokiAzureEventHubs

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.

"should be capsule, got array" when referencing encoding.from_base64() in a secret field

1 participant