{"record":{"id":"5aef7ab31d813569","repo":"juanfont/headscale","slug":"errmissingurlparameter","errorCode":"ErrMissingURLParameter","errorMessage":"missing URL parameter: %s","messagePattern":"missing URL parameter: (.+?)","errorType":"validation","errorClass":null,"httpStatus":400,"severity":"warning","filePath":"hscontrol/noise.go","lineNumber":341,"sourceCode":"\t}\n\n\tpingID := req.URL.Query().Get(\"id\")\n\tif pingID == \"\" {\n\t\thttp.Error(writer, \"missing ping ID\", http.StatusBadRequest)\n\t\treturn\n\t}\n\n\tif h.state.CompletePing(pingID) {\n\t\twriter.WriteHeader(http.StatusOK)\n\t} else {\n\t\thttp.Error(writer, \"unknown or expired ping\", http.StatusNotFound)\n\t}\n}\n\nfunc stringParam(req *http.Request, key string) (string, error) {\n\tparam := chi.URLParam(req, key)\n\tif param == \"\" {\n\t\treturn \"\", fmt.Errorf(\"%w: %s\", ErrMissingURLParameter, key)\n\t}\n\n\treturn param, nil\n}\n\nfunc nodeIDParam(req *http.Request, key string) (types.NodeID, error) {\n\tparam := chi.URLParam(req, key)\n\tif param == \"\" {\n\t\treturn 0, fmt.Errorf(\"%w: %s\", ErrMissingURLParameter, key)\n\t}\n\n\tid, err := types.ParseNodeID(param)\n\tif err != nil {\n\t\treturn 0, fmt.Errorf(\"parsing %s: %w\", key, err)\n\t}\n\n\treturn id, nil\n}","sourceCodeStart":323,"sourceCodeEnd":359,"githubUrl":"https://github.com/juanfont/headscale/blob/565fd254d06c4c7f9a8cad1714a43445c79ba420/hscontrol/noise.go#L323-L359","documentation":"Returned by stringParam when a chi URL parameter the handler expects is empty. This helper backs most noise-router handlers, so the named key in the message tells you which route parameter was missing (e.g. node, user, key).","triggerScenarios":"A Noise API request to a route whose pattern requires a parameter, but the request path omitted it — e.g. /machine/ without the id segment, or a client constructing URLs by string concatenation with an empty value.","commonSituations":"Custom automation hitting the Noise API with malformed paths; client-side bugs building request URLs; route table changes where a parameter was renamed.","solutions":["Check the error's parameter name and the route pattern in hscontrol/noise.go's router setup","Fix the caller to include the non-empty parameter in the URL path","If writing integrations, build URLs with the exact route templates the router registers"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if nodeKey := chi.URLParam(req, \"node\"); nodeKey == \"\" {\n    return errors.New(\"required URL parameter 'node' is missing\")\n}","typeGuard":null,"tryCatchPattern":"if _, err := stringParam(req, \"key\"); err != nil {\n    if errors.Is(err, ErrMissingURLParameter) {\n        // caller built a malformed URL; log the route and retry with corrected path\n    }\n}","preventionTips":["Derive request URLs from the router's registered route templates","Add integration tests covering every Noise route's required parameters"],"tags":["noise","routing","url-parameter","validation"],"backgroundTag":null,"analyzedSha":"565fd254d06c4c7f9a8cad1714a43445c79ba420","analyzedAt":"2026-08-15T13:12:30.133Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}