Sending a request with a secret URL gives an "Unable to cast value to std::string" error

Currently, calling HttpService:RequestAsync with a Url set to a secret will create an “Unable to cast value to std::string” error. This seems to NOT happen with local secrets, only when published to a game.

This place file reproduces when published to a game with the following secrets set:

  • Name: “base_url”, Secret: “https://kernel.org”, Domain: “*”
  • Name: “key”: Secret: “foobar”, Domain: “*”

Place File:
secreturlcasterror.rbxl (65,5 Kt)
Server Output:


The script contained within the place:

local HttpService = game:GetService("HttpService")

local secretBaseUrl = HttpService:GetSecret("base_url")
local secretHeader = HttpService:GetSecret("key")

local function printResponse(resp)
	if not resp.Success then
		print("Request failed")
		return
	end
	
	local body
	if string.len(resp.Body) > 100 then
		body = string.sub(resp.Body, 0, 100)
	else
		body = resp.Body
	end
	print("Request successful: ", body)
	
end

local respNoSecrets = HttpService:RequestAsync({
	Url = "https://kernel.org",
	Method = "GET",
	Headers = {
		secretheader = "foobar"
	}
})
printResponse(respNoSecrets)

local respPublicUrl = HttpService:RequestAsync({
	Url = "https://kernel.org",
	Method = "GET",
	Headers = {
		secretheader = secretHeader
	}
})
printResponse(respPublicUrl)

local respSecretUrl = HttpService:RequestAsync({
	Url = secretBaseUrl,
	Method = "GET",
	Headers = {
		secretheader = secretHeader
	}
})
printResponse(respSecretUrl)


Expected behavior

We expect the request to not return this error. Up until yesterday, this worked without issue.

A private message is associated with this bug report

1 Like

I am experiencing this same issue in my game

We’re looking into this, thanks for the report.

1 Like

Hey there, this should be fixed now, could you try again and let me know if you’re still facing the same issue?

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.