{"record":{"id":"a78bec9bb570891e","repo":"henrygd/beszel","slug":"service-name-is-required","errorCode":null,"errorMessage":"service name is required","messagePattern":"service name is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"agent/handlers.go","lineNumber":198,"sourceCode":"\n////////////////////////////////////////////////////////////////////////////\n////////////////////////////////////////////////////////////////////////////\n////////////////////////////////////////////////////////////////////////////\n\n// GetSystemdInfoHandler handles detailed systemd service info requests\ntype GetSystemdInfoHandler struct{}\n\nfunc (h *GetSystemdInfoHandler) Handle(hctx *HandlerContext) error {\n\tif hctx.Agent.systemdManager == nil {\n\t\treturn errors.ErrUnsupported\n\t}\n\n\tvar req common.SystemdInfoRequest\n\tif err := cbor.Unmarshal(hctx.Request.Data, &req); err != nil {\n\t\treturn err\n\t}\n\tif req.ServiceName == \"\" {\n\t\treturn errors.New(\"service name is required\")\n\t}\n\n\tdetails, err := hctx.Agent.systemdManager.getServiceDetails(req.ServiceName)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn hctx.SendResponse(details, hctx.RequestID)\n}\n","sourceCodeStart":180,"sourceCodeEnd":208,"githubUrl":"https://github.com/henrygd/beszel/blob/b38fb7dafa60812cc22e6a84ce313e94f1ce0a32/agent/handlers.go#L180-L208","documentation":"The systemd info handler decodes the request payload into common.SystemdInfoRequest via CBOR and requires ServiceName to be non-empty before querying systemd. This error is returned when the hub sent a SystemdInfo request whose ServiceName field is the empty string, i.e. a malformed or incomplete request.","triggerScenarios":"Calling Handle with Action = systemd info while hctx.Request.Data unmarshals into common.SystemdInfoRequest with ServiceName == \"\" — e.g. hub UI/API submitted a service lookup without selecting a service, or sent an empty/zero-value payload.","commonSituations":"A hub bug or stale frontend sending an empty systemd service name; custom API calls to the agent's systemd endpoint omitting ServiceName; CBOR payloads decoded from older/newer request shapes where the field name shifted.","solutions":["Ensure the caller (hub UI or API client) always sets ServiceName before sending a SystemdInfoRequest.","Update hub and agent to matching versions so the request schema (CBOR field names) lines up.","If calling the agent programmatically, validate the request client-side and log the payload when ServiceName is empty."],"exampleFix":"// before\nreq := common.SystemdInfoRequest{}\n\n// after\nreq := common.SystemdInfoRequest{ServiceName: \"beszel-hub.service\"}","handlingStrategy":"validation","validationCode":"if req.ServiceName == \"\" {\n    return fmt.Errorf(\"cannot query systemd: ServiceName is empty\")\n}","typeGuard":null,"tryCatchPattern":"err := handle(hctx)\nif err != nil && err.Error() == \"service name is required\" {\n    log.Warn(\"SystemdInfoRequest missing ServiceName — check hub payload\", \"data\", hctx.Request.Data)\n}","preventionTips":["Populate ServiceName from a real unit selection, never from an unset variable.","Add client-side validation of SystemdInfoRequest before serialization.","Keep hub/agent schemas in sync to avoid CBOR field drift."],"tags":["validation","systemd","request-payload","cbor"],"backgroundTag":"missing-required-field","analyzedSha":"b38fb7dafa60812cc22e6a84ce313e94f1ce0a32","analyzedAt":"2026-08-31T15:10:10.149Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}