{"record":{"id":"f30885461f4b7a3d","repo":"netbirdio/netbird","slug":"id-query-param-required","errorCode":null,"errorMessage":"id query param required","messagePattern":"id query param required","errorType":"http","errorClass":null,"httpStatus":400,"severity":"warning","filePath":"upload-server/server/server.go","lineNumber":72,"sourceCode":"\t\tdefer cancel()\n\t\treturn s.srv.Shutdown(ctx)\n\t}\n\treturn nil\n}\n\nfunc configureMux(mux *http.ServeMux) error {\n\t_, ok := os.LookupEnv(bucketVar)\n\tif ok {\n\t\treturn configureS3Handlers(mux)\n\t} else {\n\t\treturn configureLocalHandlers(mux)\n\t}\n}\n\nfunc getObjectKey(w http.ResponseWriter, r *http.Request) string {\n\tid := r.URL.Query().Get(\"id\")\n\tif id == \"\" {\n\t\thttp.Error(w, \"id query param required\", http.StatusBadRequest)\n\t\treturn \"\"\n\t}\n\n\treturn id + \"/\" + uuid.New().String()\n}\n\nfunc isValidRequest(w http.ResponseWriter, r *http.Request) bool {\n\tif r.Method != http.MethodGet {\n\t\thttp.Error(w, \"method not allowed\", http.StatusMethodNotAllowed)\n\t\treturn false\n\t}\n\n\tif r.Header.Get(types.ClientHeader) != types.ClientHeaderValue {\n\t\thttp.Error(w, \"unauthorized\", http.StatusUnauthorized)\n\t\treturn false\n\t}\n\treturn true\n}","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/netbirdio/netbird/blob/93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c/upload-server/server/server.go#L54-L90","documentation":"HTTP 400 from getObjectKey when the id query parameter is missing or empty on GET /upload-url. The id becomes the first segment of the object key (<id>/<uuid>), so an empty id is rejected before any upload URL is generated.","triggerScenarios":"GET /upload-url with no query string, ?id= (empty value), or a mis-typed parameter name such as ?peerId=...","commonSituations":"Client templates appending ?id={id} while the peer/bundle id is unset; URL builders that silently drop empty parameters; manual curl tests.","solutions":["Always send a non-empty ?id=<identifier> with GET /upload-url","Validate the id client-side before issuing the request and fail early with a clear message"],"exampleFix":"// before\nreq, _ := http.NewRequest(http.MethodGet, serverURL+\"/upload-url\", nil)\n\n// after\nq := url.Values{}\nq.Set(\"id\", bundleID)\nreq, _ := http.NewRequest(http.MethodGet, serverURL+\"/upload-url?\"+q.Encode(), nil)","handlingStrategy":"validation","validationCode":"if strings.TrimSpace(id) == \"\" {\n\treturn fmt.Errorf(\"upload id required\")\n}\nq := url.Values{\"id\": []string{id}}\nreq, err := http.NewRequestWithContext(ctx, http.MethodGet, base+\"/upload-url?\"+q.Encode(), nil)","typeGuard":null,"tryCatchPattern":"A 400 'id query param required' is deterministic: add the missing ?id= and re-issue; retrying unchanged never succeeds.","preventionTips":["Always build the query string with url.Values so empty ids are visible","Fail fast client-side when the bundle/peer id is unset instead of sending the request"],"tags":["http","query-params","upload","go"],"backgroundTag":null,"analyzedSha":"93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c","analyzedAt":"2026-08-16T03:09:19.136Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}