diff --git a/internal/store/store.go b/internal/store/store.go index 107b8ea..ccefb22 100644 --- a/internal/store/store.go +++ b/internal/store/store.go @@ -112,8 +112,16 @@ func readBody(req *http.Request) (map[string]any, error) { } err = json.Unmarshal(body, &resultMap) if err != nil { - 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)) diff --git a/sdks/python/sample/data/scones.jpg b/sdks/python/sample/data/scones.jpg new file mode 100644 index 0000000..074499b Binary files /dev/null and b/sdks/python/sample/data/scones.jpg differ diff --git a/sdks/python/sample/test-data/config/test-server-config.yml b/sdks/python/sample/test-data/config/test-server-config.yml index ebe81e6..0fada08 100644 --- a/sdks/python/sample/test-data/config/test-server-config.yml +++ b/sdks/python/sample/test-data/config/test-server-config.yml @@ -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/" diff --git a/sdks/python/sample/test-data/recordings/1bb8bed231ca5e50ed5cb037d5c4d33c6fdaa9357433c647c499c6903a69def3.json b/sdks/python/sample/test-data/recordings/1bb8bed231ca5e50ed5cb037d5c4d33c6fdaa9357433c647c499c6903a69def3.json new file mode 100644 index 0000000..7ac5928 --- /dev/null +++ b/sdks/python/sample/test-data/recordings/1bb8bed231ca5e50ed5cb037d5c4d33c6fdaa9357433c647c499c6903a69def3.json @@ -0,0 +1,56 @@ +{ + "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" + } + } + ] + } + } + ] +} \ No newline at end of file diff --git a/sdks/python/sample/test-data/recordings/models/folder1/folder2/python-sample-test_recursive_path.json b/sdks/python/sample/test-data/recordings/models/folder1/folder2/python-sample-test_recursive_path.json index 2333381..c1b2952 100644 --- a/sdks/python/sample/test-data/recordings/models/folder1/folder2/python-sample-test_recursive_path.json +++ b/sdks/python/sample/test-data/recordings/models/folder1/folder2/python-sample-test_recursive_path.json @@ -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" } } diff --git a/sdks/python/sample/test-data/recordings/python-sample-test-single-name.json b/sdks/python/sample/test-data/recordings/python-sample-test-single-name.json index b353e3e..69bca25 100644 --- a/sdks/python/sample/test-data/recordings/python-sample-test-single-name.json +++ b/sdks/python/sample/test-data/recordings/python-sample-test-single-name.json @@ -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=w5DaXbsbx%2F2PlXqycHl0ShvuHiZnHqmL5iYuP%2FD59y8HvO9KC4xSzq9mDzz6ZnENbxpU8MNfwSO8l8kUlKs47gnCup9ikRBOw%2Fam%2FU53gJ0t0RZguRAbej9OLML8jl9A%2FVggEYSJYo1A4JGuEso3uDJMMlbmp2fw1uitkAsMrl2ExUMs35uptt4R1Z3tx631YsjOGz64QlW1MZWbHQzbM0hf3Kd98%2BXJopJnudZrfxesMw%2FyOoNEWclXZS7XDWN68XKAtQl7Nqq1kS4ShsuDPQ%3D%3D--vnkZeXNoz4iRMuQH--S4gx9ntAHwkRRafwzQrJhA%3D%3D; Path=/; HttpOnly; Secure; SameSite=Lax, _octo=GH1.1.831469942.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=eym4LEHKt%2B7ZhVl8n8fL7h0YRgfMjYyi7A9PnPPB8ufVUhZHm%2BjXZkUEdmlPXEu7mifQzkNjIE%2BR%2BfjNIwRIi3xk8IY5kLgaqcHRA1g55VnGnuj0OLbQEQ5O7XXiRtEtonE7r54cGbcS1UAYo3hYr6isZDxTlpVWl%2BRU41ggapIq5WLxH%2Bb2%2Fyj%2BUwsYI91m03W4%2FNK0UBbLF46oyth1AlbT0U%2BjVI4qIzMjKnZCs51q314RP9TgJ9z6bnxFhD07D32iLiKdPLwXRioWrDGeRg%3D%3D--bb2SweHmUO8k8JXj--n%2BNFEQDGss1HyWnUIMAutg%3D%3D; Path=/; HttpOnly; Secure; SameSite=Lax, _octo=GH1.1.747190513.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:920E5EB:96857C2:68C853AF", + "X-Github-Request-Id": "DA33:29F538:11877EE:11E207D:68C999BA", "X-Xss-Protection": "0" } } diff --git a/sdks/python/sample/test-data/recordings/test_image_jpg_upload.json b/sdks/python/sample/test-data/recordings/test_image_jpg_upload.json new file mode 100644 index 0000000..f1be705 --- /dev/null +++ b/sdks/python/sample/test-data/recordings/test_image_jpg_upload.json @@ -0,0 +1,58 @@ +{ + "recordID": "test_image_jpg_upload", + "interactions": [ + { + "request": { + "method": "POST", + "url": "/upload/v1beta/files", + "request": "POST /upload/v1beta/files HTTP/1.1", + "headers": { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "Content-Length": "57", + "Content-Type": "application/json", + "Test-Name": "test_image_jpg_upload", + "X-Goog-Upload-Command": "start", + "X-Goog-Upload-Header-Content-Length": "394671", + "X-Goog-Upload-Header-Content-Type": "image/jpeg", + "X-Goog-Upload-Protocol": "resumable" + }, + "bodySegments": [ + { + "file": { + "mimeType": "image/jpeg", + "sizeBytes": 394671 + } + } + ], + "previousRequest": "b4d6e60a9b97e7b98c63df9308728c5c88c0b40c398046772c63447b94608b4d", + "serverAddress": "generativelanguage.googleapis.com", + "port": 443, + "protocol": "https" + }, + "shaSum": "f2c6a5037cb0d6b1496539c182b1ee4b7e2ec9d367ecfe576df061d369259de3", + "response": { + "statusCode": 200, + "headers": { + "Content-Length": "0", + "Content-Type": "text/plain; charset=utf-8", + "Date": "Tue, 16 Sep 2025 17:09:15 GMT", + "Server": "UploadServer", + "X-Goog-Upload-Chunk-Granularity": "8388608", + "X-Goog-Upload-Control-Url": "https://generativelanguage.googleapis.com/upload/v1beta/files?upload_id=AAwnv3IAwQ76sSSWtkOp94W-nNQLAGzqq5WadndVyvjNryp6rnZEJJ1_sO2ntd0p12NICkChbd2zSZVpsUM3qr2nEXhC6DIXeCJtvsS3bEH1Iw\u0026upload_protocol=resumable", + "X-Goog-Upload-Header-Content-Type": "application/json; charset=UTF-8", + "X-Goog-Upload-Header-Vary": "Origin, X-Origin, Referer", + "X-Goog-Upload-Header-X-Google-Backends": "unix:/tmp/esfbackend.1758016322.665428.62587", + "X-Goog-Upload-Header-X-Google-Esf-Cloud-Client-Params": "backend_service_name: \"generativelanguage.googleapis.com\" backend_fully_qualified_method: \"google.ai.generativelanguage.v1beta.FileService.CreateFile\"", + "X-Goog-Upload-Header-X-Google-Gfe-Backend-Request-Cost": "17.9547", + "X-Goog-Upload-Header-X-Google-Security-Signals": "FRAMEWORK=ONE_PLATFORM,ENV=borg,ENV_DEBUG=borg_user:genai-api;borg_job:prod.genai-api", + "X-Goog-Upload-Header-X-Google-Session-Info": "GgQYECgLIAE6IxIhZ2VuZXJhdGl2ZWxhbmd1YWdlLmdvb2dsZWFwaXMuY29t", + "X-Goog-Upload-Status": "active", + "X-Goog-Upload-Url": "http://localhost:14530/upload/v1beta/files?upload_id=AAwnv3IAwQ76sSSWtkOp94W-nNQLAGzqq5WadndVyvjNryp6rnZEJJ1_sO2ntd0p12NICkChbd2zSZVpsUM3qr2nEXhC6DIXeCJtvsS3bEH1Iw\u0026upload_protocol=resumable", + "X-Guploader-Uploadid": "AAwnv3IAwQ76sSSWtkOp94W-nNQLAGzqq5WadndVyvjNryp6rnZEJJ1_sO2ntd0p12NICkChbd2zSZVpsUM3qr2nEXhC6DIXeCJtvsS3bEH1Iw" + } + } + } + ] +} \ No newline at end of file diff --git a/sdks/python/sample/test_sample.py b/sdks/python/sample/test_sample.py index 6070e74..0e11d40 100644 --- a/sdks/python/sample/test_sample.py +++ b/sdks/python/sample/test_sample.py @@ -1,7 +1,8 @@ import pytest import requests import json -from pathlib import Path +from google import genai +import os @pytest.mark.usefixtures("managed_server") @@ -41,6 +42,19 @@ def test_should_receive_200_from_proxied_github_recursive_path(self): assert "github" in json.dumps(dict(response.headers)) print("[PyTest] Received 200 OK, content check passed.") + + def test_image_jpg_upload(self): + options_with_header = { + 'headers': { + 'Test-Name': "test_image_jpg_upload" + }, + 'base_url': "http://localhost:14530" + } + client = genai.Client(api_key=os.environ.get('GOOGLE_API_KEY'), http_options=options_with_header) + + file = client.files.upload(file='./data/scones.jpg') + print(file) + class TestAnotherSampleWithoutServer: