Skip to content

HTTP Location header seems to be using 0.0.0.0 as hostname for redirects #160

@sbv-csis

Description

@sbv-csis

When trying to use load_from_table on a bigquery-emulator process running in docker it seems like a redirect is issued that is not available "remote" - aka. other docker containers via docker network - here i've linked a bigquery-emulator(named localquery, accessed via a docker network on 172.18.0.3) container with another container in docker-compose and the inital POST goes through but the following the redirect fails:

DEBUG urllib3.connectionpool:connectionpool.py:456 http://localquery:9050 "POST /upload/bigquery/v2/projects/test-project-bla/jobs?uploadType=resumable HTTP/1.1" 200 883
DEBUG urllib3.connectionpool:connectionpool.py:228 Starting new HTTP connection (1): 0.0.0.0:9050
DEBUG urllib3.connectionpool:connectionpool.py:228 Starting new HTTP connection (2): 0.0.0.0:9050
DEBUG urllib3.connectionpool:connectionpool.py:228 Starting new HTTP connection (3): 0.0.0.0:9050
DEBUG urllib3.connectionpool:connectionpool.py:228 Starting new HTTP connection (4): 0.0.0.0:9050
DEBUG urllib3.connectionpool:connectionpool.py:228 Starting new HTTP connection (5): 0.0.0.0:9050
DEBUG urllib3.connectionpool:connectionpool.py:228 Starting new HTTP connection (6): 0.0.0.0:9050
DEBUG urllib3.connectionpool:connectionpool.py:228 Starting new HTTP connection (7): 0.0.0.0:9050

I dont know if just a path-only redirect would work generally - or at all:

diff --git a/server/handler.go b/server/handler.go
index a18af66..3452acd 100644
--- a/server/handler.go
+++ b/server/handler.go
@@ -268,8 +268,7 @@ func (h *uploadHandler) serveResumable(w http.ResponseWriter, r *http.Request) {
        w.Header().Add(
                "Location",
                fmt.Sprintf(
-                       "%s/upload/bigquery/v2/projects/%s/jobs?uploadType=resumable&upload_id=%s",
-                       addr,
+                       "/upload/bigquery/v2/projects/%s/jobs?uploadType=resumable&upload_id=%s",
                        project.ID,
                        job.JobReference.JobId,
                ),

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions