From 69a9361177e550f7e7343a9b1847a0442bc2ddfb Mon Sep 17 00:00:00 2001 From: Bryant Jimin Son <5396174+bryantson@users.noreply.github.com> Date: Sun, 20 Apr 2025 19:49:09 -0500 Subject: [PATCH] Fix error with agent requests header to X-GitHub-Public-Key-Signature The current application fails to start with "go run ." with a following error: "failed to validate payload signature: asn1: syntax error: sequence truncated." After some debugging, the error happens to due to "sig" value in the line of "sig := r.Header.Get("GitHub-Public-Key-Signature")" of "service.go" file's "ChatCompletion" function returning nothing. This happened because the header changed from "GitHub-Public-Key-Signature" to "XGitHub-Public-Key-Signature" as seen here: https://docs.github.com/en/copilot/building-copilot-extensions/building-a-copilot-agent-for-your-copilot-extension/configuring-your-copilot-agent-to-communicate-with-github#verifying-that-payloads-are-coming-from-github --- agent/service.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/agent/service.go b/agent/service.go index 59ea8e3..8b64262 100644 --- a/agent/service.go +++ b/agent/service.go @@ -39,7 +39,7 @@ func NewService(pubKey *ecdsa.PublicKey) *Service { } func (s *Service) ChatCompletion(w http.ResponseWriter, r *http.Request) { - sig := r.Header.Get("Github-Public-Key-Signature") + sig := r.Header.Get("X-GitHub-Public-Key-Signature") body, err := io.ReadAll(r.Body) if err != nil {