diff --git a/src/common/libflux/response.c b/src/common/libflux/response.c index a265d17844ef..08723f2bd546 100644 --- a/src/common/libflux/response.c +++ b/src/common/libflux/response.c @@ -315,8 +315,10 @@ int flux_respond_error (flux_t *h, const flux_msg_t *request, { flux_msg_t *msg = NULL; - if (!h || !request || errnum == 0) + if (!h || !request) goto inval; + if (errnum == 0) + errnum = EINVAL; if (flux_msg_is_noresponse (request)) return 0; msg = flux_response_derive (request, errnum); diff --git a/src/common/libflux/response.h b/src/common/libflux/response.h index 781a4e2edfb2..101f05c1ebf5 100644 --- a/src/common/libflux/response.h +++ b/src/common/libflux/response.h @@ -86,7 +86,8 @@ int flux_respond_raw (flux_t *h, const flux_msg_t *request, const void *data, int len); /* Create an error response to the provided request message with optional - * error string payload (if errstr is non-NULL). + * error string payload (if errstr is non-NULL). If errnum is zero, EINVAL + * is substituted. */ int flux_respond_error (flux_t *h, const flux_msg_t *request, int errnum, const char *errstr);