{"record":{"id":"526164c8ecad5d91","repo":"tailscale/tailscale","slug":"expected-method-get-or-put","errorCode":null,"errorMessage":"expected method GET or PUT","messagePattern":"expected method GET or PUT","errorType":"http","errorClass":null,"httpStatus":405,"severity":"error","filePath":"feature/taildrop/peerapi.go","lineNumber":157,"sourceCode":"\t\t\toffset = ranges[0].Start\n\t\t}\n\t\tn, err := taildropMgr.PutFile(clientID(fmt.Sprint(id)), baseName, r.Body, offset, r.ContentLength)\n\t\tswitch err {\n\t\tcase nil:\n\t\t\td := ext.Clock().Since(t0).Round(time.Second / 10)\n\t\t\th.Logf(\"got put of %s in %v from %v/%v\", approxSize(n), d, h.RemoteAddr().Addr(), h.Peer().ComputedName)\n\t\t\tio.WriteString(w, \"{}\\n\")\n\t\tcase ErrNoTaildrop:\n\t\t\thttp.Error(w, err.Error(), http.StatusForbidden)\n\t\tcase ErrInvalidFileName:\n\t\t\thttp.Error(w, err.Error(), http.StatusBadRequest)\n\t\tcase ErrFileExists:\n\t\t\thttp.Error(w, err.Error(), http.StatusConflict)\n\t\tdefault:\n\t\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\t}\n\tdefault:\n\t\thttp.Error(w, \"expected method GET or PUT\", http.StatusMethodNotAllowed)\n\t}\n}\n\nfunc approxSize(n int64) string {\n\tif n <= 1<<10 {\n\t\treturn \"<=1KB\"\n\t}\n\tif n <= 1<<20 {\n\t\treturn \"<=1MB\"\n\t}\n\treturn fmt.Sprintf(\"~%dMB\", n>>20)\n}\n","sourceCodeStart":139,"sourceCodeEnd":170,"githubUrl":"https://github.com/tailscale/tailscale/blob/6e0912f97994f927632b34ae9e63b53d6516a6ac/feature/taildrop/peerapi.go#L139-L170","documentation":"Method guard in the peerapi file-put handler (handlePeerPutWithBackend path): the incoming peer request used an HTTP method other than GET or PUT, which are the only methods the inbound Taildrop peerapi endpoint accepts.","triggerScenarios":"Thrown at feature/taildrop/peerapi.go:157 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use HTTP GET to download or PUT to upload a taildrop file."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"6e0912f97994f927632b34ae9e63b53d6516a6ac","analyzedAt":"2026-08-18T08:17:25.280Z","contentChangedAt":"2026-08-18T08:17:25.280Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}