Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions internal/store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,16 @@ func readBody(req *http.Request) (map[string]any, error) {
}
err = json.Unmarshal(body, &resultMap)
if err != nil {
Copy link
Collaborator Author

@wanlin31 wanlin31 Sep 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the data can't be json.unmarshal, they can be the byte data from file upload. We let the byte data fall through to req.body without changing it.

log.Fatalf("Error unmarshaling JSON: %v", err)
return nil, err
contentType := http.DetectContentType(body)
isBinary := strings.HasPrefix(contentType, "image/") ||
strings.HasPrefix(contentType, "video/") ||
strings.HasPrefix(contentType, "audio/") ||
contentType == "application/pdf" ||
contentType == "application/octet-stream"
if !isBinary {
log.Printf("Error unmarshaling JSON: %v", err)
return nil, err
}
}
// Restore the request body for further use.
req.Body = io.NopCloser(bytes.NewBuffer(body))
Expand Down
Binary file added sdks/python/sample/data/scones.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions sdks/python/sample/test-data/config/test-server-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,19 @@ endpoints:
source_type: http
source_port: 17080
health: /healthz
- target_host: generativelanguage.googleapis.com
target_port: 443
source_port: 14530
source_type: http
target_type: https
health: /healthz
redact_request_headers:
- X-Goog-Api-Key
- Authorization
- X-Goog-User-Project
- User-Agent
- X-Goog-Api-Client
response_header_replacements:
- header: X-Goog-Upload-Url
regex: "^https://generativelanguage.googleapis.com/"
replace: "http://localhost:14530/"
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This new file is part of the file upload, there was issue inside the genai python file upload, the headers are not passing through, have an internal fix for that.

"recordID": "1bb8bed231ca5e50ed5cb037d5c4d33c6fdaa9357433c647c499c6903a69def3",
"interactions": [
{
"request": {
"method": "POST",
"url": "/upload/v1beta/files?upload_id=AAwnv3IAwQ76sSSWtkOp94W-nNQLAGzqq5WadndVyvjNryp6rnZEJJ1_sO2ntd0p12NICkChbd2zSZVpsUM3qr2nEXhC6DIXeCJtvsS3bEH1Iw\u0026upload_protocol=resumable",
"request": "POST /upload/v1beta/files?upload_id=AAwnv3IAwQ76sSSWtkOp94W-nNQLAGzqq5WadndVyvjNryp6rnZEJJ1_sO2ntd0p12NICkChbd2zSZVpsUM3qr2nEXhC6DIXeCJtvsS3bEH1Iw\u0026upload_protocol=resumable HTTP/1.1",
"headers": {
"Accept": "*/*",
"Accept-Encoding": "gzip, deflate",
"Connection": "keep-alive",
"Content-Length": "394671",
"X-Goog-Upload-Command": "upload, finalize",
"X-Goog-Upload-Offset": "0"
},
"bodySegments": [
null
],
"previousRequest": "b4d6e60a9b97e7b98c63df9308728c5c88c0b40c398046772c63447b94608b4d",
"serverAddress": "generativelanguage.googleapis.com",
"port": 443,
"protocol": "https"
},
"shaSum": "c68c1d24af03f4c1b178db5de0a98fac46a05cc85b5b613d3fbd36b1c677d699",
"response": {
"statusCode": 200,
"headers": {
"Content-Length": "505",
"Content-Type": "application/json; charset=UTF-8",
"Date": "Tue, 16 Sep 2025 17:09:16 GMT",
"Server": "UploadServer",
"Vary": "Origin, X-Origin, Referer",
"X-Goog-Upload-Status": "final",
"X-Guploader-Uploadid": "AAwnv3IAwQ76sSSWtkOp94W-nNQLAGzqq5WadndVyvjNryp6rnZEJJ1_sO2ntd0p12NICkChbd2zSZVpsUM3qr2nEXhC6DIXeCJtvsS3bEH1Iw"
},
"bodySegments": [
{
"file": {
"createTime": "2025-09-16T17:09:16.260393Z",
"expirationTime": "2025-09-18T17:09:15.811243885Z",
"mimeType": "image/jpeg",
"name": "files/6xve7iakq5ng",
"sha256Hash": "NzQ1MDVjZDc1OTJiMTBiYzJkNGU5YzRhYTQyOTg2NmRlNzNmNDAzZGIxMWVkZDk1YjViNDAwNGFlYTdlMTM3Ng==",
"sizeBytes": "394671",
"source": "UPLOADED",
"state": "ACTIVE",
"updateTime": "2025-09-16T17:09:16.260393Z",
"uri": "https://generativelanguage.googleapis.com/v1beta/files/6xve7iakq5ng"
}
}
]
}
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,18 @@
"Cache-Control": "max-age=0, private, must-revalidate",
"Content-Encoding": "gzip",
"Content-Language": "en-US",
"Content-Security-Policy": "default-src 'none'; base-uri 'self'; child-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/; connect-src 'self' uploads.github.com www.githubstatus.com collector.github.com raw.githubusercontent.com api.github.com github-cloud.s3.amazonaws.com github-production-repository-file-5c1aeb.s3.amazonaws.com github-production-upload-manifest-file-7fdce7.s3.amazonaws.com github-production-user-asset-6210df.s3.amazonaws.com *.rel.tunnels.api.visualstudio.com wss://*.rel.tunnels.api.visualstudio.com objects-origin.githubusercontent.com copilot-proxy.githubusercontent.com proxy.individual.githubcopilot.com proxy.business.githubcopilot.com proxy.enterprise.githubcopilot.com *.actions.githubusercontent.com wss://*.actions.githubusercontent.com productionresultssa0.blob.core.windows.net/ productionresultssa1.blob.core.windows.net/ productionresultssa2.blob.core.windows.net/ productionresultssa3.blob.core.windows.net/ productionresultssa4.blob.core.windows.net/ productionresultssa5.blob.core.windows.net/ productionresultssa6.blob.core.windows.net/ productionresultssa7.blob.core.windows.net/ productionresultssa8.blob.core.windows.net/ productionresultssa9.blob.core.windows.net/ productionresultssa10.blob.core.windows.net/ productionresultssa11.blob.core.windows.net/ productionresultssa12.blob.core.windows.net/ productionresultssa13.blob.core.windows.net/ productionresultssa14.blob.core.windows.net/ productionresultssa15.blob.core.windows.net/ productionresultssa16.blob.core.windows.net/ productionresultssa17.blob.core.windows.net/ productionresultssa18.blob.core.windows.net/ productionresultssa19.blob.core.windows.net/ github-production-repository-image-32fea6.s3.amazonaws.com github-production-release-asset-2e65be.s3.amazonaws.com insights.github.com wss://alive.github.com wss://alive-staging.github.com api.githubcopilot.com api.individual.githubcopilot.com api.business.githubcopilot.com api.enterprise.githubcopilot.com github.githubassets.com edge.fullstory.com rs.fullstory.com; font-src github.githubassets.com; form-action 'self' github.com gist.github.com copilot-workspace.githubnext.com objects-origin.githubusercontent.com; frame-ancestors 'none'; frame-src viewscreen.githubusercontent.com notebooks.githubusercontent.com www.youtube-nocookie.com; img-src 'self' data: blob: github.githubassets.com media.githubusercontent.com camo.githubusercontent.com identicons.github.com avatars.githubusercontent.com private-avatars.githubusercontent.com github-cloud.s3.amazonaws.com objects.githubusercontent.com release-assets.githubusercontent.com secured-user-images.githubusercontent.com/ user-images.githubusercontent.com/ private-user-images.githubusercontent.com opengraph.githubassets.com marketplace-screenshots.githubusercontent.com/ copilotprodattachments.blob.core.windows.net/github-production-copilot-attachments/ github-production-user-asset-6210df.s3.amazonaws.com customer-stories-feed.github.com spotlights-feed.github.com objects-origin.githubusercontent.com *.githubusercontent.com images.ctfassets.net/8aevphvgewt8/; manifest-src 'self'; media-src github.com user-images.githubusercontent.com/ secured-user-images.githubusercontent.com/ private-user-images.githubusercontent.com github-production-user-asset-6210df.s3.amazonaws.com gist.github.com github.githubassets.com assets.ctfassets.net/8aevphvgewt8/ videos.ctfassets.net/8aevphvgewt8/; script-src github.githubassets.com; style-src 'unsafe-inline' github.githubassets.com; upgrade-insecure-requests; worker-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/",
"Content-Security-Policy": "default-src 'none'; base-uri 'self'; child-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/; connect-src 'self' uploads.github.com www.githubstatus.com collector.github.com raw.githubusercontent.com api.github.com github-cloud.s3.amazonaws.com github-production-repository-file-5c1aeb.s3.amazonaws.com github-production-upload-manifest-file-7fdce7.s3.amazonaws.com github-production-user-asset-6210df.s3.amazonaws.com *.rel.tunnels.api.visualstudio.com wss://*.rel.tunnels.api.visualstudio.com github.githubassets.com objects-origin.githubusercontent.com copilot-proxy.githubusercontent.com proxy.individual.githubcopilot.com proxy.business.githubcopilot.com proxy.enterprise.githubcopilot.com *.actions.githubusercontent.com wss://*.actions.githubusercontent.com productionresultssa0.blob.core.windows.net/ productionresultssa1.blob.core.windows.net/ productionresultssa2.blob.core.windows.net/ productionresultssa3.blob.core.windows.net/ productionresultssa4.blob.core.windows.net/ productionresultssa5.blob.core.windows.net/ productionresultssa6.blob.core.windows.net/ productionresultssa7.blob.core.windows.net/ productionresultssa8.blob.core.windows.net/ productionresultssa9.blob.core.windows.net/ productionresultssa10.blob.core.windows.net/ productionresultssa11.blob.core.windows.net/ productionresultssa12.blob.core.windows.net/ productionresultssa13.blob.core.windows.net/ productionresultssa14.blob.core.windows.net/ productionresultssa15.blob.core.windows.net/ productionresultssa16.blob.core.windows.net/ productionresultssa17.blob.core.windows.net/ productionresultssa18.blob.core.windows.net/ productionresultssa19.blob.core.windows.net/ github-production-repository-image-32fea6.s3.amazonaws.com github-production-release-asset-2e65be.s3.amazonaws.com insights.github.com wss://alive.github.com wss://alive-staging.github.com api.githubcopilot.com api.individual.githubcopilot.com api.business.githubcopilot.com api.enterprise.githubcopilot.com edge.fullstory.com rs.fullstory.com; font-src github.githubassets.com; form-action 'self' github.com gist.github.com copilot-workspace.githubnext.com objects-origin.githubusercontent.com; frame-ancestors 'none'; frame-src viewscreen.githubusercontent.com notebooks.githubusercontent.com www.youtube-nocookie.com; img-src 'self' data: blob: github.githubassets.com media.githubusercontent.com camo.githubusercontent.com identicons.github.com avatars.githubusercontent.com private-avatars.githubusercontent.com github-cloud.s3.amazonaws.com objects.githubusercontent.com release-assets.githubusercontent.com secured-user-images.githubusercontent.com/ user-images.githubusercontent.com/ private-user-images.githubusercontent.com opengraph.githubassets.com marketplace-screenshots.githubusercontent.com/ copilotprodattachments.blob.core.windows.net/github-production-copilot-attachments/ github-production-user-asset-6210df.s3.amazonaws.com customer-stories-feed.github.com spotlights-feed.github.com objects-origin.githubusercontent.com *.githubusercontent.com images.ctfassets.net/8aevphvgewt8/; manifest-src 'self'; media-src github.com user-images.githubusercontent.com/ secured-user-images.githubusercontent.com/ private-user-images.githubusercontent.com github-production-user-asset-6210df.s3.amazonaws.com gist.github.com github.githubassets.com assets.ctfassets.net/8aevphvgewt8/ videos.ctfassets.net/8aevphvgewt8/; script-src github.githubassets.com; style-src 'unsafe-inline' github.githubassets.com; upgrade-insecure-requests; worker-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/",
"Content-Type": "text/html; charset=utf-8",
"Date": "Mon, 15 Sep 2025 17:58:03 GMT",
"Etag": "W/\"cd488b2ea2ae9702b6652dfcb4294b9f\"",
"Date": "Tue, 16 Sep 2025 17:09:13 GMT",
"Etag": "W/\"1520ee8faeb34290495d951d5bc58b5d\"",
"Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
"Server": "github.com",
"Set-Cookie": "_gh_sess=3YXTN2Kn9fZ548MFymDvF4bmU3CVT1fhBeYO4rhAseW2l4rkmT0wzpD6sxgKPmt6uiXpcanTYQoSk0His54Z5ZVw1bPeaynC5BS5XzhvbMHfO4jT%2Ffg7udqglbBw1lmCRyr34q2WlFb%2F%2BM5aF3ErLwjPQUIHzxN1MH12fLFOxbh919Qvxs%2FEc%2FEdCQkb6a5wSvhYSihZXyGtDSQkRN%2FtE74aZZzOhn9hhHo68SeDmE47VCWIRm%2Bk1MGP3C6YiXwHjHF3T0%2Bu4OupJqUgKvKkbw%3D%3D--q7RzlJy371g%2FhXQu--2ZImD096TJjWHHRIqjJi%2Bg%3D%3D; Path=/; HttpOnly; Secure; SameSite=Lax, _octo=GH1.1.1334543195.1757959087; Path=/; Domain=github.com; Expires=Tue, 15 Sep 2026 17:58:07 GMT; Secure; SameSite=Lax, logged_in=no; Path=/; Domain=github.com; Expires=Tue, 15 Sep 2026 17:58:07 GMT; HttpOnly; Secure; SameSite=Lax",
"Set-Cookie": "_gh_sess=64nA9oJ4egK%2F%2FUw9j78gFed2t4uwwztm4ahQXvIhxzie3nG4l%2BDZrJqjfp3%2F%2FZ9EBoqDfegPVoKRVgMqD0HY2Q8QCzzdW3%2BymCF5rJprIkfH8o%2FiwTfT2oPLhqSldefYAsLg%2FqnWCOhnSNV2BJysnqbrISdcgy475QbydV2ZPYtZvrSBT6VuWDJhnUg9%2BrY2X3Kp1%2BZtfMPWYzrdjBLtZ0NsrQ75MYoEeHjNtguUPGcc%2BzUwU3kzWtBTLRo06DheIAvcT6%2FMMHtBe1kucfl6qA%3D%3D--I%2F%2Byci4w4DJN%2Besi--chMu%2BdpDWZzJy7P0aXTUjQ%3D%3D; Path=/; HttpOnly; Secure; SameSite=Lax, _octo=GH1.1.1777788255.1758042554; Path=/; Domain=github.com; Expires=Wed, 16 Sep 2026 17:09:14 GMT; Secure; SameSite=Lax, logged_in=no; Path=/; Domain=github.com; Expires=Wed, 16 Sep 2026 17:09:14 GMT; HttpOnly; Secure; SameSite=Lax",
"Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
"Vary": "X-PJAX, X-PJAX-Container, Turbo-Visit, Turbo-Frame, X-Requested-With, Accept-Language,Accept-Encoding, Accept, X-Requested-With",
"X-Content-Type-Options": "nosniff",
"X-Frame-Options": "deny",
"X-Github-Request-Id": "D872:2A9986:920E617:96857F7:68C853AF",
"X-Github-Request-Id": "DA33:29F538:1187812:11E20A5:68C999BA",
"X-Xss-Protection": "0"
}
}
Expand Down
Loading
Loading