diff --git a/src/modules/job-list/job_data.c b/src/modules/job-list/job_data.c index 1222e68a62b7..1bb2227cb38a 100644 --- a/src/modules/job-list/job_data.c +++ b/src/modules/job-list/job_data.c @@ -385,7 +385,20 @@ int job_parse_jobspec_fatal (struct job *job, const char *s, json_t *updates) return job_jobspec_update (job, updates); } -static int parse_R (struct job *job, const char *s, bool allow_nonfatal) +static int load_R (struct job *job, const char *s, bool allow_nonfatal) +{ + json_error_t error; + + if (!(job->R = json_loads (s, 0, &error))) { + flux_log (job->h, LOG_ERR, + "%s: job %s invalid R: %s", + __FUNCTION__, idf58 (job->id), error.text); + return allow_nonfatal ? 0 : -1; + } + return 0; +} + +static int parse_R (struct job *job, bool allow_nonfatal) { struct rlist *rl = NULL; struct idset *idset = NULL; @@ -396,13 +409,6 @@ static int parse_R (struct job *job, const char *s, bool allow_nonfatal) struct rnode *rnode; int saved_errno, rc = -1; - if (!(job->R = json_loads (s, 0, &error))) { - flux_log (job->h, LOG_ERR, - "%s: job %s invalid R: %s", - __FUNCTION__, idf58 (job->id), error.text); - goto nonfatal_error; - } - if (!(rl = rlist_from_json (job->R, &error))) { flux_log_error (job->h, "rlist_from_json: %s", error.text); goto nonfatal_error; @@ -456,12 +462,16 @@ static int parse_R (struct job *job, const char *s, bool allow_nonfatal) int job_parse_R (struct job *job, const char *s) { - return parse_R (job, s, true); + if (load_R (job, s, true) < 0) + return -1; + return parse_R (job, true); } int job_parse_R_fatal (struct job *job, const char *s) { - return parse_R (job, s, false); + if (load_R (job, s, false) < 0) + return -1; + return parse_R (job, false); } int job_jobspec_update (struct job *job, json_t *updates)